this code:
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public GameObject ObjectB;
public GameObject ObjectA;
transform.position = ObjectA.transform.position;
}`
is giving me an error. The error is “UNEXPECTED SYMBOL ‘=’ in class, struct, or interface member declaration”. this is on the transform.position = ObjectA.transform.position; I have looked every where but can not find out how to get rid of this error. Thanks in advance.
yes you should write transform.position = ObjectA.transform.position; in any of the function. You cannot write that line where variables/objects are declared.
– united4lifethank you but how would i make it every time I spawn one make it go strait to objectA. thank you so much. I have an object called bullet that is meant to spawn right on the Object called doombot but so far it spawns in the corner of my screen (no idea why this happens). how would i make it spawn right at the doom bot or transport to the doombot right as it is created. thank you
– mindstormermageIf I understand correctly, something like this could work. Set doombot's tag as "doombot" and have this code in a script which is attached to the bullet. void Start() { transform.position = GameObject.FindWithTag("doombot").transform.position; }
– hamstar