The Aeroplane in Action!

It's been a remarkably productive couple of days!  That's not like me at all!

Anyhoo, thanks to the glorious Godot Engine, I now have the plane in a scene and a gunsight (made in Inkscape) moved around by a USB game controller.  Nice!


I use the x and y from the controller's analog stick and map that onto viewport space to produce a screen position, using the likes of:

cameraNode.get_viewport().get_visible_rect().size.x 

Then, I use the camera to project that position into 3D space with

var projectVector = cameraNode.project_ray_normal(screenPoint);

Finally, I scale that up to the z-distance I want the gunsight at and set that position on the gunsight node!

    gunsightNode.translation = projectVector*(100/-projectVector.z);

Then, it's just a case of making the plane point at it, and adding a little roll:

    playerMeshNode.transform = playerMeshNode.transform.looking_at(
                                 gunsightNode.transform.origin, Vector3(0,1,0)
                              );
    playerMeshNode.rotation_degrees.z = -55*x;


et voila! :D


Comments

Popular posts from this blog

Micro:Bit and SPI display

DCS World with TrackIR under Ubuntu

Cardboard Mock-up of USB Joystick