Jump to content

How to make a P2 body accelerate along the x-axis?


ChubbRck
 Share

Recommended Posts

Hi all,

 

Trying to make a P2 body accelerate (as opposed to using moveLeft) but am having a tough time, tried to use applyForce like this:

 basket.body.data.applyForce([100,100], basket.x, basket.y);

As well as this..

 basket.body.data.applyForce([100,100], [basket.x, basket.y]);

with no results.  Anyone know what I'm doing wrong? I have tried changing the 100 to a number much larger as well as change gravityScale back to 1 (it is currently at 0).

 

Thanks - 

 

Nick

Link to comment
Share on other sites

Think you need to use the second version. And you also need to do it every frame. Is that what you do?

 

If it does not work, you can always do this (every frame):

basket.body.data.force[0] = 100;basket.body.data.force[1] = 100;

The .applyForce method does this - adds to the force vector.

 

Stefan

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...