transform.position - transform.position returns float?

I want to lock on an enemy:

var lockOnTarget = enemy.position - currentChar.position;
    	Debug.Log(lockOnTarget);
    	forward = Vector3.Angle(lockOnTarget, currentChar.position);

Both enemy and currentChar are transform, but console says: “BCE0022: Cannot convert ‘float’ to ‘UnityEngine.Vector3’.” for 3rd line. When i print the lockOnTarget to the console, it returns: “(0.0, 0.0, 25.3)”.

2 Answers

2

No. It returns Vector3 as stated here.

However. Vector3.Angle DOES return float. Your forward variable is of type Vector3. This is what error is reporting.

Because your forward variable is of type Vector3 and the Vector3.Angle function returns a float.