so I am making a 3D game that you are a UFO, move around and suck up different items, i have those items with rigidbody and when it collide with a invisible box, it attract to the ufo, if I put the those items as gameObject in the hierachy, it works that it got suck into the ufo, but when i turn them into prefab and have a spawner to spawn them, when the invisible box collide with the object, it got attract to the Player original spawn point, any idea why? Im quite new to Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyNoscore : MonoBehaviour
{
public GameObject Cube;
public GameObject Player;
public float Speed;
public int scoreValue = 1;
public Rigidbody Rigidbody;
public bool useG = true;
public GravityBody GravityBody;
public AIWandering AI;
public Timer timer;
void Start()
{
timer = GetComponent<Timer>();
}
void Update ()
{
Instantiate(Rigidbody);
Cube.transform.position = Vector3.MoveTowards(Cube.transform.position, Player.transform.position, Speed * Time.deltaTime);
}
void OnTriggerEnter(Collider Coll)
{
if (Coll.gameObject.tag == "Looking")
{
Speed = 150f;
}
else
{
Speed = 0f;
}
}
void Awake()
{
Rigidbody = GetComponent<Rigidbody>();
}
}