Jump to content


Photo

Need help with finding when x stops changing


  • Please log in to reply
5 replies to this topic

#1 rgrambo

rgrambo

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM8

Posted 10 March 2012 - 09:42 AM

Im creating a game where i have a unit being launched to the right, with friction slowing him down. I want to create a stop variable such that
if "unit stopped" then stop = 1
but i can not find anything that will work to let me know when the unit has stopped moving. I have tried if x=xprevious, but it is always true for some reason.

Any help would be appreciated.
Thank you

Edited by rgrambo, 10 March 2012 - 09:42 AM.

  • 0

#2 creativebunch

creativebunch

    The Bunchiest

  • GMC Member
  • 886 posts
  • Version:GM:Studio

Posted 10 March 2012 - 09:55 AM

Check the speed:
if (speed == 0) stop = 1;

  • 0

#3 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2438 posts
  • Version:GM:Studio

Posted 10 March 2012 - 10:02 AM

When using speed, the coordinates aren't changed before after the step event, so if I'm correct in assuming you're doing the check in step event, x will always be equal to xprevious. If you really want to use that check, do it in end step event instead! :)
Though, if you use the speed variable, you can simply check for "if speed=0"

Creativebunch, you ninja!

Edited by TheSnidr, 10 March 2012 - 10:02 AM.

  • 0

#4 Rhodox

Rhodox

    GMC Member

  • GMC Member
  • 132 posts

Posted 10 March 2012 - 11:29 AM

you could do

if x = xprevious and y = previous {
//Do something
}

in the step event
  • 0

#5 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2438 posts
  • Version:GM:Studio

Posted 10 March 2012 - 11:55 AM

you could do

if x = xprevious and y = previous {
//Do something
}

in the step event

No, that's what he said he already tried. It has to go in an event executed after step event, in which case the end step event is a perfect option
  • 0

#6 rgrambo

rgrambo

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM8

Posted 10 March 2012 - 04:56 PM

Wow im an idiot. Lol thank you. Speed works perfectly :P
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users