Hello,
I’m having a bit of trouble getting a platform to move between a certain path with AS3.
My code looks like this -
if (((_platform.x >= 300) && (_sp >0)) || ((_platform.x <= 50) && (_sp <0)))
{
_sp *= -1;
}
_platform.x += _sp;
where _sp is the speed at which the platform moves (currently at 7) and _platform is the instance name of the platform.
I want it to move between the coordinates 50 and 300 along the x axis. What it does is, moves along the x axis and as soon as _platform.x hits 300 I get this weird movement where the platform moves back and forth at this point. Any idea why it’s happening as I am switching the direction as seen in the code.