Character Movement (Velocity question)

About advanced scenes, and the Thyme scripting language used in Algodoo.

Re: Character Movement (Velocity question)

Postby Kilinich » Tue Sep 20, 2016 5:07 pm

e.this.vel = e.this.vel = [2, 0]

what should that do? why x = x = y ?
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Character Movement (Velocity question)

Postby FRA32 » Tue Sep 27, 2016 9:40 pm

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).
FRA32
 
Posts: 229
Joined: Wed Dec 03, 2014 9:51 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron