The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

The setting is Isometric perspective 3D scene with orthogonal static(not following the player) camera, using a gridmap with mesh shapes for the terrain.

What I'm trying to achieve here is get the mouse position on the terrain when clicked to be able to send a projectile in the direction of mouse pointer, which I was able to do by connecting the inputevent() signal of each meshinstance in said gridmap to player body which is painfully stupid process, and doesn't work if clicked outside of said gridmap.
And the other thing is to rotate player character towards the mouse cursor at all times which I tried setting up screen raycast as stated in documentation, but couldn't get it to work right.

Anyone can help me on this and spare me any more headache please?

in Engine by (129 points)

1 Answer

0 votes
Best answer

Found a solution:

Created an invisible plane mesh over the whole world with higher Y axis than everything else, and used intersect_ray() function to intersect the camera raycast with it, then used the x and z translation of this raycast vector and player y translation to get a directional vector3() for rotation and projectiles.

by (129 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.