hi is there any way to measure the acceleration of an object so I can trigger an event according to the objects movement for example: if acceleration in the y-axis is more then 0 (moving up), set a var to true, but if acceleration in y is less then 0 (moving down), the var is false this would really help me out thanks in advance
Three Vector3 variables. Swapping between them, first one is the third last update. Second is the second update. Third is the newest update. Update them based on what current frame you're at and you get this: Acceleration = (Second - First) - (Third- Second) I THINK that should work, not sure. That's off the top of my head.
if you use this technique of moving: creating a Vector3, and modifying its x, y, z values according to the key pressed (Input.GetAxis()), and moving the player by the Vector, than you can do it: for example: PHP: var moveDir = Vector3.zero; var speed = 10; var jumpHeight = 5; var gravity = 9; var controller; function Awake() { controller = GetComponent(CharacterController); } function Update() { moveDir.x = Input.GetAxis("Horizontal") * speed; moveDir.z = Input.GetAxis("Vertical") * speed; if(Input.GetKeyDown("space") controller.isGrounded) { moveDir.y = jumpHeight; } moveDir.y -= gravity * Time.deltaTime; controller.Move(moveDir * Time.deltaTime); } than you can check if the player is going up: PHP: if(moveDir.y > 0) or check if its going forward: PHP: if(moveDir.z > 0) or down: PHP: if(moveDir.y < 0) left: PHP: if(moveDir.x < 0) right: PHP: if(moveDir.x > 0) back: PHP: if(moveDir.z < 0) hope it helps.