I know this happens because I assign a new value to all instances, but how do I make each instance have a separate value
PlayerScript
void Update()
{
movementDir = new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
movement = movementDir.normalized * Playerspeed * Time.deltaTime;
transform.position = transform.position + movement;
if (Input.GetKeyDown(KeyCode.DownArrow))
{
GameObject BulletInstance = Instantiate(bullet, transform.position, Quaternion.identity);
direction = Vector3.down;
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{
GameObject BulletInstance = Instantiate(bullet, transform.position, Quaternion.identity);
direction = Vector3.up;
}
}
Projectile
public Player myPlayer;
void Start()
{
myPlayer= GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
}
void Update()
{
transform.Translate(myPlayer.direction * 4 * Time.deltaTime, Space.World);
}