I'm in need of a little help.
Generally I have no problem with vectors when it comes to 3d stuff, but I have no clue how 2d equivalents work.
Basically here's the outline:
I have this biped set up to fire a cube out of his hand, basically. Now, two problems are faced here:
You can see my poor attempts at doing a sort of linear velocity right off the bat. The other problem was the angles; I had to hack a + 90 degree turn on the cube because it was facing the wrong way, and I'm not sure if what I'm doing is correct.
In any case, what I want is a cube to fire from his hand in the direction that the hand is facing, and I don't know enough about 2d to accomplish this (back in 3d (euler angles, of course) I would use something like Angles_Vectors to get the forward vector from the angles, and multiply the origin by a scale amount in the forward direction and use that as the velocity)
Any ideas?
-P
Generally I have no problem with vectors when it comes to 3d stuff, but I have no clue how 2d equivalents work.
Basically here's the outline:
I have this biped set up to fire a cube out of his hand, basically. Now, two problems are faced here:
Code:
// Shoot bullet test
b2Vec2 test = TheBiped->LHand->GetPosition();
BulletBody *Bullet = new BulletBody (test, 3, 1, b2Color(1,1,1), -1, TheBiped->LHand->GetAngle() + DEG2RAD(90));
b2Vec2 Vel = b2Cross(Bullet->PhysicsBody->GetPosition(), TheBiped->LHand->GetAngle());
Bullet->PhysicsBody->SetLinearVelocity(Vel);
//Bullet->PhysicsBody->ApplyImpulse (Vel, Bullet->PhysicsBody->GetLocalCenter());
b2Vec2 test = TheBiped->LHand->GetPosition();
BulletBody *Bullet = new BulletBody (test, 3, 1, b2Color(1,1,1), -1, TheBiped->LHand->GetAngle() + DEG2RAD(90));
b2Vec2 Vel = b2Cross(Bullet->PhysicsBody->GetPosition(), TheBiped->LHand->GetAngle());
Bullet->PhysicsBody->SetLinearVelocity(Vel);
//Bullet->PhysicsBody->ApplyImpulse (Vel, Bullet->PhysicsBody->GetLocalCenter());
You can see my poor attempts at doing a sort of linear velocity right off the bat. The other problem was the angles; I had to hack a + 90 degree turn on the cube because it was facing the wrong way, and I'm not sure if what I'm doing is correct.
In any case, what I want is a cube to fire from his hand in the direction that the hand is facing, and I don't know enough about 2d to accomplish this (back in 3d (euler angles, of course) I would use something like Angles_Vectors to get the forward vector from the angles, and multiply the origin by a scale amount in the forward direction and use that as the velocity)
Any ideas?
-P