Hi All,
I have a working piece of code that I'm trying to replicate in Playmaker.
Basically it is used to rotate an object towards the position of the mouse, in this case the turret on my battle tank.
var traverseSpeed : float = 360; // degrees per second
function Update (){
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var dist : float;
var plane : Plane = new Plane(Vector3.up, transform.position);
if(plane.Raycast(ray, dist)){
var rotation : Quaternion= Quaternion.LookRotation(ray.GetPoint(dist) - transform.position);
transform.rotation = Quaternion.RotateTowards(transform.rotation, rotation, traverseSpeed * Time.deltaTime);
}
}
I am not sure how to set the "ray" and "plane" variables and do the "if" statement.
How would I turn this into a state machine, or is there are better/simpler way of doing it within Playmaker??
Many thanks