Hello,
I have an object on the layer. When a user touches a place on the screen I want the object to have an initial force applied and head in that direction. I just can't get my head around the vector maths to apply the force in the right direction.
Here is a diagram with an example what I am trying to achieve:
http://imgur.com/uCXuqCode:
// Need to apply a force between the object current location and where the user clicked.
b2Vec2 force = b2Vec2(clickLocation.x/PTM_RATIO, clickLocation.y/PTM_RATIO);
gameObject.body->SetLinearVelocity(force);
The setLiniearVelocity seems to apply the force I require but there is one huge flaw, the objects ALWAYS go to the right. If I click left to the object I want the object to go left. I think the problem is I am always passing a positive vector in.