This script is attached to many gameObjects and prefabs.
Firstly, here is the code I need help with:
function Update(){
var fwd = transform.TransformDirection (-Vector3.forward);
if (Physics.Raycast (transform.position, fwd, 1)) {
placedObject = true;
}
}
The problem is with the public boolean placedObject. I want it to be set true if there is something in front of an object (if there is an object in front, placedObject is true), but instead it is setting true to the object which is in front (if this object is in front of another object, placedObject is true).
Please format your code (use the 101010-Button). Also make sure to read the [docs][1] if you are not sure how raycasts work. [1]: http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html
– Lockstep