- Home /
Mouse Click Teleportation with 2.5d game
So I'm creating a 2.5d game and I want the character to teleport to a certain location after I click the mouse, I have this code and the player teleports to the main camera every time I click the mouse, is there a way I can get the character to go exactly where I can click the mouse? Also is it possible to have multiple times the player can disappear before the powerup affect goes away? Thanks
private Transform player;
void Awake() { //Find the player object and set it player = GameObject.FindGameObjectWithTag("Player").transform; }
void Update() { // Check if you click the left mouse button then change position if (Input.GetMouseButtonDown(0)) player.position = Camera.main.ScreenToWorldPoint(Input.mousePosition); }
Your answer
![](https://koobas.hobune.stream/wayback/20220613020622im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
onmousedown on object teleport 1 Answer
Player Car Runtime Scaling Issue 0 Answers
Teleportation Loop issue 1 Answer
Transform to a random height 0 Answers