Im trying to move a body upon touch. So I set it up in the object's class method and in the update I do this:
Now when I use #1. (changing the velocity)it works, he jumps. But when I use #2. (applyLinearImpulse) he doesnt move at all.
What could be the problem?
I just changed it to ApplyForce and it works. I guess I dont understand it as well as I thought I did.
Code:
double timeJumping = CACurrentMediaTime()-jumpStartTime;
if (jumpStartTime != 0 && timeJumping < 0.25) {
//1.This is setting the velocity
//currentVel.y = jumpFactor*2;
//2.This is applying an impulse
NSLog(@"jumping because of jumpStarttime");
body->ApplyLinearImpulse( b2Vec2(0,5000), self.body->GetWorldCenter() );
//self.body->SetLinearVelocity(currentVel);
}
if (jumpStartTime != 0 && timeJumping < 0.25) {
//1.This is setting the velocity
//currentVel.y = jumpFactor*2;
//2.This is applying an impulse
NSLog(@"jumping because of jumpStarttime");
body->ApplyLinearImpulse( b2Vec2(0,5000), self.body->GetWorldCenter() );
//self.body->SetLinearVelocity(currentVel);
}
Now when I use #1. (changing the velocity)it works, he jumps. But when I use #2. (applyLinearImpulse) he doesnt move at all.
What could be the problem?
I just changed it to ApplyForce and it works. I guess I dont understand it as well as I thought I did.