- Home /
Question by
emmiboii · May 10, 2021 at 11:00 PM ·
triggerobjectunity 2dvisual studiovisualstudio
move object when player reach trigger
I saw someone else ask this but var doesnt work on visual studio 2019, so could anyone help me?
Comment
Is something like this what you are looking for?
public Vector3 warpTarget = new Vector3(0f, 0f, 0f);
private void OnTriggerEnter(Collider other)
{
Warp();
}
public void Warp()
{
ThirdPersonController player = GameObject.FindWithTag("Player").GetComponent<ThirdPersonController>();
player.controller.Move(warpTarget - player.playerLocation);
}
Your answer
Follow this Question
Related Questions
csc.exe has stopped working ,csc.exe has stoped working 0 Answers
2D game object trigger 1 Answer
Removing "Development build" text in a Windows Store App 0 Answers
How to instantiate prefab when colliding with specified prefab 1 Answer
How do I pick up an object and place it in a spot that kind of like a missing puzzle piece? 0 Answers