- Home /
Question by
Mikez · Aug 02, 2012 at 06:36 PM ·
transform.positiondistance
transform.position not a member of system.type
I have been trying to figure out this problem for a while, but I could not quite catch it. The coding makes sense to my eyes, however after trying out several variables, including code-splits, the error still persists. The problem is marked in an arrow. Any solution to this persisting problem will be greatly appreciated.
var target = Transform;
var playerCam : Camera;
var boatCam : Camera;
var triggerDistance : float = 5;
var decisionGUI = guiTexture;
function Start(){
boatCam.enabled = false;
decisionGUI.enabled = false;
}
function Update () {
var distance = (target.position - transform.position).sqrMagnitude; <- problem
if (distance < triggerDistance){
decisionGUI.enabled = true;
if (Input.GetKey("G")){
gameObject.GetComponent(Motor).BoatToggle();
playerCam.enabled = false;
boatCam.enabled = true;
}
}
if (distance > triggerDistance){
decisionGUI.enabled = false;
}
}
Comment
Your answer
Follow this Question
Related Questions
How to move an object immediately to a desired location? 2 Answers
GameObject1 move away when GameObject2 gets close 1 Answer
How to make the object stop moving within a certain distance with the target. 1 Answer
teleport an object three quarters of its distance with the player after a certain time 2 Answers