hey, i want the walking speed go higher when i press down, and lower when i press up, but i cant figure it out, it works nicely with z values but with speed it doesnt work, maybe im doing it wrong, heres what i have using z , when i change it to speed and give min 22 and max 55 then it just doesnt work :
How do you guys limit the speed and put a clamp on it ?
In this script when character is at Z 800 then his speed is not accelerating anymore, when hes at z 600 then speed is not decelerating , now i just want to make it work by using walking speed values so its consistent.
How do you guys limit the speed and put a clamp on it ?
In this script when character is at Z 800 then his speed is not accelerating anymore, when hes at z 600 then speed is not decelerating , now i just want to make it work by using walking speed values so its consistent.
Code:
@script
void self = getlocalvar("self");
int pindex = getentityproperty(self,"playerindex");
float sp = getentityproperty(self,"speed");
float z = getentityproperty(self,"z");
void yVel = getlocalvar("yVel"+self);
int minspeed = 22;
int maxspeed = 55;
void moveup = playerkeys(pindex, 0, "moveup");
void movedown = playerkeys(pindex, 0, "movedown");
void vspeed ;
settextobj(1, 250 , 280 , 1, 1,getentityproperty(self,"speed")/100+"speed", openborvariant("elapsed_time")+2000);
settextobj(2, 250 , 180 , 2, 2, z , openborvariant("elapsed_time")+2000);
if ( !vspeed ){
setlocalvar("vspeed",22*1000);
}
if (getentityproperty(self,"speed") && z >= 600 && moveup ) {
changeentityproperty(self, "speed", (getentityproperty(self,"speed"))- 0.05);
}
if (getentityproperty(self,"speed")&& z <= 800 && movedown ) {
changeentityproperty(self, "speed", (getentityproperty(self,"speed"))+ 0.05);
}
@end_script