0 votes

Hello community, I am once again asking for your implementation aid :)

I am currently trying to implement a compass for VR, it should always face the forward direction. I somewhat reached this using the look_at() function. My problem is that when pitching the compass the mesh and the texture showing the cardinal directions will collide in one another resulting in a look like this:


Anyone got a quick idea on how i could avoid this behaviour? I know it is kind of hard since you will it actually does what it should do, as it always points towards the north (forward) direction.

in Engine by (39 points)

Why are the mesh and the texture two different objects? If you have to keep them separate for some reason, then instead of rotating the mesh, couldn't you rotate a parent common to both the texture and the mesh?

I don't really understand what you want to achieve. If you want to avoid clipping, but still have wind rose flat, you can, for example, make it render on top of that mesh. You could also make that mesh slightly transparent, or just put that wind rose higher.

1 Answer

0 votes

This help me: using A to B compass angle. If B is north of A the angle is 0 radians:

public float getDirection(Vector3 vA, Vector3 vB){
        //only plane XZ
        vA = new Vector3(vA.x, 0, vA.z);
        vB = new Vector3(vB.x, 0, vB.z);

        Vector3 dir = vB-vA; 
        float angle = Vector3.Forward.AngleTo(dir); //angle with "nort"

        if (dir.x<0){
            angle = (2*Mathf.Pi) - angle; 
        return angle; 

In python same logic.

by (32 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 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 webmaster@godotengine.org with your username.