- Home /
How to change the angle my character falls at
I want my Character to be on a platform, and have the platform rotate in all angles. I want my character to have the ability to be upside down on the platform.
Answer by 2d4Games · Aug 15, 2013 at 01:48 AM
Add a check on the character that checks if the character is on that special platform or not. If the player is on the platform, then set the direction of the gravity to be towards the platform.
You can do this by getting the down vector from the platform (negative up vector), and setting the transformation equation for gravity to be a scalar multiple of that vector.
Something like this:
var gravity : float;
var gravDirection = Vector3.down;
function Update (){
if (onPlatform){
gravDirection = -Platform.gameObject.GetComponent(Transform).up;
}
transform.position = gravDirection * gravity * Time.deltaTime;
}
Your answer
Follow this Question
Related Questions
Character too floaty after jumping and grappling.,Grapple too floaty 0 Answers
CharacterController isGrounded toggles value 2 Answers
Face direction to move in 2 Answers
Rotate character to the moving direction problems? 2 Answers
Character Controller Movement - Different speeds on different axis 1 Answer