1
General / Re: Inverting velocity to bounce an object (along x-axis)
« on: April 17, 2017, 02:44:18 pm »
Ok so I have managed to solve this!
in the IF statement I changed it to getPosition().x instead of position.x
So it looks like this:
Incase anyone else has a similar problem!
in the IF statement I changed it to getPosition().x instead of position.x
So it looks like this:
Code: [Select]
void Enemy3::update(float dt)
{
// moving from left to right of the screen and having negative gravity effecting the y movement
if ([b]getPosition.x[/b] >= 800)
{
velocity.x= -velocity.x;
}
if ([b]getPosition.x[/b] <= 0)
{
velocity.x = -velocity.x;
}
move(velocity * dt);
updateAABB(); // updating AABB collision
}
Incase anyone else has a similar problem!