- Home /
Scripting, Rotate and set gravity on collision
I am making a game where there is a ramp and as the player moves on the ramp the rotation and the gravity of all the objects in the scene change to that angle and as the player moves up the ramp the angle changes until it reaches 90 degrees PLEASE HELP looked everywhere cant find anything. here are before and after pics of what it should look like.
it is not scripted just placed the objects. i have some knowledge of code but this is a tad to advanced for me please help it will be greatly appreciated.
Answer by OllyNicholson · Apr 15, 2013 at 11:19 AM
Hi - you may still need assistance with the scripting (perhaps see collaboration section on the forums?) but essentially you should be able to update the orientation of your player at each frame by raycasting down at the surface your player is on and comparing the surface normal with the world orientation to perform a calculation and accordingly update the player orientation at every frame. This would allow for your objects to behave correctly with the new gravity orientation as your player moves up the ramp.
http://docs.unity3d.com/Documentation/ScriptReference/RaycastHit-normal.html
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Rotational Gravity - Camera and Force problems 1 Answer
Applying force with respect to angle with the ground? 1 Answer
rotation relative to world / starting position 1 Answer
How to tilt the gameobject based of Input.Acceleration? 0 Answers