- Home /
Rotating Children as Rigidbodies2D because transform rotation is too costly
Well it turns out to be quite the fiddling with the physics engine. But here is where I am stuck orjust need some timeout because I had enough...
2D Spaceship TwinStickShooter. I got like 300-500 pooled projectiles flying, homing and ricochetting at a stable fps of around 150 (hopefully it is my shitty laptop makes this drop to that low fps...).
I got a Problem with activating and disabling the Gameobjects, as this seems to be expensive.
Now I built a turret mounted on the ship.
The turret gets parented at a relative position of a child Transform. rotating this at some point becomes costly. I tried to replace the transform rotation with a rigidbody rotation, but whenI'm doing this, it doesn't stay put and I have to actualize its position, which is another pain, as rigidbody.position gets materialized in the fixedupdate cycle, so I can't just update it in the regular Update cycle.
I don't know If i'Il have to use a rigidbody without a collider, with a collider and what I have to do to make it stay put in position.
Am trying to align the rigidbody's velocity with the ship's, maybe that'll solve the problem, but I have just reverted to the transform solution. Am doing it tomorrow.
Right now I'm just stumped. Is there a better trnasform rotation solution I'm missing, because Physics2D.UpdateTransforms explodes when I push an enemy ship around, making it rotate... with just 5 ships floating around (each 2 turrets)
So, Any suggestions?^^
(maybe I could stabilize the ships rotation through the yet nonexistent AI maybe that will help to stop too much rotation. on the other hand: why is rotating so costly, that makes it such a big deal?)
Alright I leave it for you now, I got to get some sleep...
I cannot see how using the physics engine to do a rotation could possibly be more efficient that perfor$$anonymous$$g the rotation on your own. The final step: adjusting the rotation, should even be the same. Perhaps you used a costly method to compute the rotation needed, or something like that (targeting CAN be expensive, depending on how you do it).
Your answer
Follow this Question
Related Questions
Rotation issue with remote players projectiles 0 Answers
How to lock X rotation; broken script 0 Answers
Network Transform Slow Rotations 0 Answers
How to find the angle of a rotation? 1 Answer
Separate child rotation 1 Answer