Understanding Vectors and RayCast - Scripting

Hi @Stefan and @Dmitry,

I’m trying to implement a cursor-controlled teleport, and am getting an issue where the camera is teleported too far. I’m sure it’s something to do with local/world or some clash, but it’s stumped me.

Any insight you can provide would be appreciated!

Thanks in advance,
Geoff @ TechLeap

Hi @techleapnz,

The camera is teleporting too far because the position of the camera is set for every frame while the right mouse button is clicked down. This behavior is coming from the Input.onKeyPressed handler.

If you want your camera to be teleported only once when the right mouse button is clicked, you can either use Input.onKeyDown (when right mouse button is clicked down) or Input.onKeyUp (when right mouse button is released).

Hope this helps!

1 Like

Perfect. Thanks @Stefan!

1 Like