Greetings,
Can I add velocity to an object relative to it’s local axis?
This is the snippet of code:
rigidbody.velocity.z = MovSpeed;
But it’s relative to the world, I want it to be relative to the local object.
Here is the full script.
private var lookRotationPoint = Vector3;
public var MovSpeed : float = 10.00;
function Update()
{
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast(ray, hit))
{
if (hit.collider.gameObject.tag == "Plane")
{
var lookRotationPoint = hit.point - transform.position;
transform.rotation = Quaternion.LookRotation(lookRotationPoint.normalized);
transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);
}
if(Input.GetMouseButton(1))
{
"Code goes here"
}
if(!Input.GetMouseButton(1))
{
rigidbody.velocity = Vector3(0,0,0);
}
}
}