var towerGhost : Transform;
var towerActual : Transform;
var gridPoint : Vector3;
function Update () {
var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var ghostTower : Transform;
if ( Physics.Raycast( ray, hit, 100 ) ){
if (hit.collider.CompareTag("gridFloor")){
gridPoint = hit.collider.transform.position;
if(gridPoint != null){
if(Input.GetMouseButtonDown(0)){
ghostTower = Instantiate(towerGhost,gridPoint,Quaternion.identity);
}
if(Input.GetMouseButton(0)){
ghostTower.position = gridPoint;
}
}
if(Input.GetMouseButtonUp(0)){
Instantiate(towerActual,gridPoint,Quaternion.identity);
}
}
}
}
does anybody know why this wouldn’t be working?
both ghost tower and gridpoint have been assigned and are showing up in debug.log i dont get it
Update: ok so i posted my entire script hoping it would make more sense now.
gridPoint is a Vector3, no? If ghostTower is a transform, you really don't need the .gameObject.transform bit to refer to itself...
– syclamothi guess i should add that the object i am trying to move has just been instantiated at gridPoint and now it wont track to my current grid point, and i just deleted the gameObject and transform, but still no cigar
– IMTRIGGERHAPPY9