Character Movement (Velocity question)
2 posts • Page 1 of 1
Re: Character Movement (Velocity question)
e.this.vel = e.this.vel = [2, 0]
what should that do? why x = x = y ?
what should that do? why x = x = y ?
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Character Movement (Velocity question)
Put this in postStep (the standard area for in-scene-code):
vel=[0,vel(1)]; //(Disables any horizontal movement)
keys.isDown("Right") ? {
vel=vel+[2,0]
} : {}
keys.isDown("Left") ? {
vel=vel-[2,0]
} : {}
keys.isDown("Up") && !_jump ? {
vel=vel+[0,4];
_jump = true;
} : {}
vel = [vel(0), vel(1)-9.81/sim.frequency] //(replace 9.81 with any number to adjust the falling accelleration, or leave line out if you use scene gravity)
The code makes the character move to the left/right when you have the button pressed and makes it jump upwards as long as the _jump variable is false. If the left/right button is not pressed, the velocity turns 0. If you use the last line, it will fall down at the rate you wish(undertale has slow falling).
vel=[0,vel(1)]; //(Disables any horizontal movement)
keys.isDown("Right") ? {
vel=vel+[2,0]
} : {}
keys.isDown("Left") ? {
vel=vel-[2,0]
} : {}
keys.isDown("Up") && !_jump ? {
vel=vel+[0,4];
_jump = true;
} : {}
vel = [vel(0), vel(1)-9.81/sim.frequency] //(replace 9.81 with any number to adjust the falling accelleration, or leave line out if you use scene gravity)
The code makes the character move to the left/right when you have the button pressed and makes it jump upwards as long as the _jump variable is false. If the left/right button is not pressed, the velocity turns 0. If you use the last line, it will fall down at the rate you wish(undertale has slow falling).
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
2 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests