Timeline for setTransform() Box2D physics not working
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 11, 2020 at 20:43 | vote | accept | Rohan | ||
Aug 11, 2020 at 19:18 | answer | added | bornander | timeline score: 1 | |
Aug 11, 2020 at 17:48 | comment | added | DMGregory♦ | That might be a good question to edit your post to ask. "Not working" isn't really a question, but "How do I..." is. :) | |
Aug 11, 2020 at 17:47 | comment | added | Rohan | Now that you point that out, you're right. Since I'm setting the body position every frame, that makes sense. How do you suggest I read the new position based on where the physics engine pushed the body? | |
Aug 11, 2020 at 17:22 | comment | added | DMGregory♦ |
It looks like you always force the physics body to match your position variable every frame (so if the physics engine tried to move the bodies apart, you undo that and force them back together), and you never read a new position out of the physics body to update this position variable. So the communication is one-way. No matter what happens in the physics simulation, your code doesn't care - it never asks the physics engine where it should move to. Am I misunderstanding your code?
|
|
Aug 11, 2020 at 17:14 | history | asked | Rohan | CC BY-SA 4.0 |