- Home /
Ball physics and camera rotation determined by ball's collision contact normal
Another day, another dead-end regarding my little ball prototype! I was, in fact, expecting to come across yesterday, before the collision detection not working wasted my day.
I have a physics-controlled ball, inside of which there is an empty gameobject which is locked to the ball's position while independent of rotation - the camera, in turn, is parented to this - the result being a freely-controllable camera. When W is pressed, force is applied to the ball in the direction that the camera is looking - I then zero the y value to get a nice even force. I also have to zero the camera's z rotation in order to stop it from resting at inappropriate angles as a result of the free camera control.
Basically, this is way too limiting for what I have in mind. There's a couple of things in particular I'd like to change:
Removing the Z angle from the camera direction when applying force doesn't seem like it'll work with a loop-the-loop or other extreme steep angles. I'm struggling to find a way to flatten out the force, not via the global Z, but relative to the normal of the ball's contact point with the level - I'm sure it's possible, but I don't know where to start.
I'd also like the camera's default "up" direction to equal the contact point's normal. I've noticed that I cannot move my camera further foward around the ball when it is vertically above it - obviously this is the behaviour I want, but again it will prove inconvenient in loop-the-loop type situations where you need to follow the ball all the way round.
I've got the contact point as a variable, so there's no problem accessing the normal, it's more a question of how to implement it in this way.
It's a bit of a strange one to describe, so here's a picture of what I mean:
Your answer
![](https://koobas.hobune.stream/wayback/20220612142433im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
open camera on android with orientation? 1 Answer
Jittery Movement - specific mechanics in mind 0 Answers
Player in Spaceship 2 Answers
Colliders not working on camera frustrum. 0 Answers
Re-orienting Player after changing direction of Gravity 0 Answers