How can I move a object whit annother script?
I have try to move the object but i can't get it to work.;) I have test it so her.
public bool point = false; private int points = 0; public Text Text; public bool Starts = true; public GameObject player1; void Start() { player1 = GameObject.Find ("Player").GetComponent (); } void OnTriggerEnter2D (Collider2D other) { point = true; Starts = true; } void Update() { Text.text = "Points: " + points.ToString(); if (point == true) { print ("funkar"); if (Starts == true)
{
points += 1;
print (points);
point = false;
Starts = false;
player1 = transform.Translate (0, 0, 0);
}
}
Answer by ZealAura · Apr 07, 2017 at 03:50 PM
You're example is a bit difficult to understand, please put your code in proper code snippet format. I'll just mention this, you can also create a public gameObject variable of player within the other script you want to use it in.
for example:
public GameObject _playerHolder;
void getThePlayerScript()
{
_playerHolder.getComponent<playerScript>().transform.position = new vector3 (1.0f, 1.0f, 1.0f);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612114924im_/https://answers.unity.com/themes/thub/images/avi.jpg)