Directional Velocity Problems

You must understand the Game Editor concepts, before post here.

Directional Velocity Problems

Postby code4242 » Mon Jul 11, 2011 11:42 pm

I'm trying to use directional velocity to work my movement system when the player Key Up's a directional key. But when I Key Up, it makes the character move the other way instead of stopping. Any ideas what I'm doing wrong? Also, if anyone has an easier/better way to make a movement system, please mention it.

Code: Select all
if (Boldar.directional_velocity=-12)
{
xvelocity=0;
}


PS. I'm starting the movement with xvelocity=12
Current project: Teratism
User avatar
code4242
 
Posts: 40
Joined: Tue Dec 11, 2007 9:01 pm
Location: Sitting at my laptop :D
Score: 0 Give a positive score

Re: Directional Velocity Problems

Postby DST » Tue Jul 12, 2011 1:00 am

use
if (Boldar.directional_velocity==-12)
{
xvelocity=0;
}

By using only one =, you were setting it to -12. Also, you have mixed directional_velocity with xvelocity?

Best way is to make a use variable, named something like dir.

Then on keydown, you set dir to something.....0 for right, 1 for up,2 for left, and so on. Then in draw actor, you can assign movement based on what value dir is.

You don't really need a keyup, just set dir to 0 at the END of draw actor. Then next frame, if they've got the key down, it will set it to a number again (use repeat on the keydown).

You can say directional_velocity=12; angle=dir*90;
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest