Hi everyone,
I’d like to know if there is any possible way of adding forces to a sphere from its own axis, I mean, when I apply the force it applies to the “global axis” and i want it to the objects axis.Here is part of my script, where I add the force to the ball:
var ballVelocity=100;
var dir : Vector3 = Vector3.zero;
dir.x = Input.acceleration.x;
dir.z = Input.acceleration.y;
if (dir.sqrMagnitude > 1){
dir.Normalize();
dir *= Time.deltaTime;
rigidbody.AddForce(dir * ballVelocity);
}
if the ball is spinning in any way (for example, rolling around), its local axes are gonna be in a 'random' position every time you apply force, which would result in unpredictable behaviour. an option that players might like would be applying forces from the camera's local axes, which are predictable and should make sense to the player. :) look for 'unity camera relative movement' for the functions and stuff to convert directions from camera to world and back. But if you do want local-axis forces, Fattie's got you covered.
– LoiusThanks for so quick responses :) That was the option i hoped will work well, but i didn't knew if it was possible. I see that it is... ;D Will this let me move a ball in the direction the cam is looking? Thanks again :)
– Scorpox