Using p2.js in my project changed the positioning of elements in my project after launch and i don’t know how to fix it. Need help in fixing it.
I think you need a number of corrections on your fence entities:
- Avoid nesting your fences like this, having a model being a child of a p2 body:
Instead add all of them as first level children to Root or another non p2 body entity. Then add the p2Box and p2Body scripts to all four of them.
- Your fences I think should be static bodies? If they aren’t meant to move by physics then consider that.
Ok let’s ignore fences. For now look at the car. It rotates automatically when i launch the project. If i can fix that . The fences can come afterwards
The car is set up with some rotations:
If I zero out those rotations, I get:
Just looking at the p2.js integration code, it assumes there’s no rotation (or scale!) on the body entity.
So, if I were you, I would create a child of the car_1 entity called ‘model’ or something, and add the model component there. You can then apply any rotation and scale to the child to align the car model with the p2 body parent.
Thanks a lot. After applying everything you said I finally got the basics of it’s working.