i have a very simple scene which has a sphere and a cube. All i am trying to do is set the location of the cube always behind the sphere at a certain defined distance(i defined a variable distanceaway in the script for setting this distance).
OUTPUT:
the cube is not put at the location i expected and no matter what the value of the variable distanceaway is set the cube’s location is unaltered.(i attached an image of the ouput where i circled the cubes position in playmode).
The script is attached to the sphere and takes the Transform of the cube as an input.
I would guess (didnt test it)
Cube.postion = transform.position + (transform.forward * distanceaway);