- Home /
Question by
chronicfail · May 11, 2013 at 09:03 PM ·
raycastbce0023rock
BCE0023: No appropriate version of 'UnityEngine.Transform.LookAt' for the argument list '(UnityEngine.RaycastHit)' was found.
I am trying to make a script for a rocket launcher with rockets that look towards where you point the mouse, so that if you hold the mouse over the target the rocket will aim towards it. I am using this code on the launcher:
var hit: RaycastHit;
if (Physics.Raycast(BarrelEnd.position, BarrelEnd.forward, hit)){
rocketClone.SendMessage("track",hit);
which works fine
and this code on the rocket
function track(tracker : RaycastHit){ Transform.LookAt(tracker); }
which doesn't work. I am a noob to unity and can't find a way to fix this, so please could someone help.
Comment
Best Answer
Answer by aldonaletto · May 11, 2013 at 09:09 PM
You're trying to look at a RaycastHit structure, what will never work. Look at tracker.transform or tracker.point instead:
function track(tracker: RaycastHit){
transform.LookAt(tracker.transform); // it's transform, not Transform!
}
This makes the object look at the hit object position. If you pass tracker.point, the object will look at the hit point.