[ 11 posts ]  Reply to topicPost new topic 
Author Message
 [gb]
 Post subject: Slopes Problem
PostPosted: Mon Aug 12, 2013 8:34 pm 
User avatar
Member
I'm making a Yoshi's Island game, and I'm having trouble getting Yoshi to walk up and down slopes. I'm using a parent object for the slopes, and I'm using the following codes to handle the collision:

Yoshi step event:
Code:
var slope;
slope = instance_position(x,bbox_bottom+4, obj_slope_parent)
if (slope <> noone){
    while not(place_meeting(x,y+1,slope))
         y += 1
}
Yoshi collision event with slope parent object:
Code:
while place_meeting(x,y, obj_slope_parent)
       y -= 1
This code doesn't seem to work though. Yoshi just sticks to the slope like this when he lands on it and doesn't go up or down it, like this (sorry for the bad screenshot, as it was really just to test it)

Image

How can I fix this?

_________________
Image
 
Top
Offline 
 
 
 [us]
 Post subject: Re: Slopes Problem
PostPosted: Mon Aug 12, 2013 8:48 pm 
User avatar
Lawful Evil
Member
[*]
[*]
[*]
[*]
[*]

[*]
What comparator is <>? I've never seen that one before.

And where is Yoshi's origin?

And are slopes parented to any kind of solid? You didn't seem to put any 'landing' code in the "stick to a slope that's under you" event, so it seems like you would be making it a solid, but, if it isn't, that could be the problem. If it is parented to a solid, Yoshi might just be getting stuck in the slope, which would be a problem with where he's snapping to, which depends on where his origin is...

and if it's not parented to a Solid but uses Game Maker's inbuilt 'Solid' system instead, that's a horrible horrible problem that must be fixed immediately

because Game Maker's inbuilt system for handling solid collisions is weird and funky


Last edited by Magnemania on Mon Aug 12, 2013 8:54 pm, edited 1 time in total.
_________________
Image
Magikoopa Security Force, the Mario Action-Strategy game!
  It's time to fight for Bowser!
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: Slopes Problem
PostPosted: Mon Aug 12, 2013 8:54 pm 
User avatar
Member
As far as I know, <> means "not". That line of code is basically saying "if slope = true". Yoshi's sprite x-origin is centered, but his sprite y-origin is at the bottom of each sprite. The slope parent object is parented to the solid flat ground object, and both use Game Maker's built-in solid variable. I'm using Ultramario's Yoshi engine in which the ground object is 'solid'. I didn't change it because I didn't think I'd have this problem, but if that's what could be contributing to the issue, I'd better change it.

_________________
Image
 
Top
Offline 
 
 
 [us]
 Post subject: Re: Slopes Problem
PostPosted: Mon Aug 12, 2013 9:21 pm 
User avatar
もう帰らない
Member
[*]
[*]
[*]
[*]
Yuck, the only language I'm aware of where "<>" is the standard operator to use for "not equal to" is Visual Basic. != is so much more intuitive and nicer-looking.

The code you show looks just fine, but it doesn't strike me as something that would cause slope behavior. It just makes sure you're always on top of the slope (actually, this could introduce bugs; jumping into a slope from the bottom could put you on top of it). It also seems like you're relying on precise collision detection when a mathematical formula based on the character's horizontal position relative to the slope would probably be better.

I've never actually done slopes myself, so sorry if what I'm saying is a little generic.

EDIT: Game Maker's automatic "solid" handling is going to screw slopes up. What it does is automatically put whatever collides with it to the previous position. You'll need to disable it, or work around it somehow.

_________________
https://onpon4.github.io
 
Top
Offline 
 
 
 [us]
 Post subject: Re: Slopes Problem
PostPosted: Mon Aug 12, 2013 11:24 pm 
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Brute force to-top method, I see. I believe this would work better if place_meeting is replaced by collision_point, and the x and y arguments rounded.

What handles his animations?

_________________
"talk about dang ol' this ain't scientific rockets, man"
Spoiler:
Bibby Team - Nice little place. Give it a try.
 
Top
Offline 
 User page at mfgg.net
 
 [gb]
 Post subject: Re: Slopes Problem
PostPosted: Tue Aug 13, 2013 11:23 am 
User avatar
Member
Miles wrote:
What handles his animations?

Sorry if the answer to this question is obvious, but what do you mean by that?

_________________
Image
 
Top
Offline 
 
 
 [tr]
 Post subject: Re: Slopes Problem
PostPosted: Tue Aug 13, 2013 11:46 am 
User avatar
Thanks DonnieTheGuy!
Administrator
[A]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
Jeorge535 wrote:
Miles wrote:
What handles his animations?

Sorry if the answer to this question is obvious, but what do you mean by that?

I think he thought the problem is Yoshi's animation.

_________________
Image
 
Top
Offline 
 
 
 [us]
 Post subject: Re: Slopes Problem
PostPosted: Tue Aug 13, 2013 5:55 pm 
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
Nah, I didn't think there was a problem with the animation, I was just curious about something that's pretty much unrelated to the matter at hand. My mistake. Anywho, have you tried replacing position_meeting with collision_point? That's how I've been doing it.

_________________
"talk about dang ol' this ain't scientific rockets, man"
Spoiler:
Bibby Team - Nice little place. Give it a try.
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Slopes Problem
PostPosted: Tue Aug 13, 2013 6:00 pm 
Member
[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
there's one thing that's minor but can be prohibiting better detection. Have you ticked 'same as sprite' for the mask in Yoshi's object or are you using a proper mask?

_________________
Spoiler:
 
Top
Offline 
 
 
 [gb]
 Post subject: Re: Slopes Problem
PostPosted: Tue Aug 13, 2013 6:10 pm 
User avatar
Member
Miles: Yeah, I tried replacing place_meeting with collision_point. Didn't seem to work though, so it looks like I might need to replace the 'solid' ground objects with non-solid ones.

LuigiM9: I'm using a proper mask for Yoshi.

_________________
Image
 
Top
Offline 
 
 
 [tr]
 Post subject: Re: Slopes Problem
PostPosted: Tue Aug 13, 2013 6:20 pm 
User avatar
Thanks DonnieTheGuy!
Administrator
[A]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
Jeorge535 wrote:
so it looks like I might need to replace the 'solid' ground objects with non-solid ones.

Problem solved.

_________________
Image
 
Top
Offline 
 
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
 [ 11 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group