Rotation about a pivot point not working using script?

Hi, hope this is posted in the correct place:

Would greatly appreciate some help in how to keep the rotation fixed about the little airplane by either:

  1. python scripting
    or
  2. use of logic bricks

Please see link here:

https://youtu.be/jNMOieOlVQw

I don’t understand why the rotation (banking) of the plane symbol is messed up.
Note: Only the background (Blue sky and brown earth) is moving up and down with W and S keys. The airplane symbol stays fixed.
Thank you so much.

Hi technomark! you need to make a gyroscope system, the central sight should never rotate and move it is static, the plane with horizontal marks moves and rotates, the movement does not occur as adding positions through the motion actuator but as the position of the horizontal scale on the Z-axis-horisontPlane.worldPosition = [own.wolrdPosition[0], own.worldPosition[1], +0.1], or make a horizontal marker with the digits in the form of a ball with markings texture which copies the map rotation on the X Y axis, then when lifting the nose of your gyro will show the elevation angle or Vice versa the angle of incidence relative to the horizon (your map) and the sight (circle) will not run away to the side on the markup

Villi89, Thank you so much for your reply. Before I embark on this gyroscope system, is it a seriously complicated piece of software program + physics? Or is it something within my level of challenge (I’m only an intermediate programmer and intermediate Blender user)?
I don’t want to get into something way over my ability to finish.
My initial thought that this would be a short 10 - 20 line python script project. Am I thinking too simply?
Thanks for your help. :woozy_face: :

technomark - to create the gyroscope is not difficult - you need an object that will constantly copy the rotation of the horizon line, for example, the object will map - a gyro sphere that constantly copies the rotations of the card on the XY axes of this sphere you want to be the descendant of your device in your flying the plane due to the fact that the map is always static, the gyro will always show deviations of your plane from the horizon line - you can test it is to create a dashboard where the gyro will scope and establish a control to it using the mouse to rotate your plane and the sphere which is a descendant of this dashboard script copy axis displays the deviation of the aircraft

Viktor…
Thank you very much for your advice.
So, at least it’s within my reach. I do some research in that direction and see if I can make it work.
Thanks again for your great help!

I’ll try to make an example as soon as I have time

Thank you, Viktor. That would be a great help.

Very easy to explain, objects rotate around their privot/origin (orange dot). So when you move it up or down the origin position changes and it will rotate at that point.

you simply need two align axis to vectors. one for the Z, and the other for the Y (forward)

the python version is like this:

owner = scene.objects["Suzanne"]
gyro = scene.objects["Icosphere"]

yref = owner.getAxisVect([0,1,0]) #get aircraft forward
zref = [0,0,1] #world Z

gyro.alignAxisToVect(yref, 1, 1.0) #align to aircraft
gyro.alignAxisToVect(zref, 2, 1.0) #align to world

a simple indicator would only even need just a z constraint even (no edit object actuator or yref align)

oooo WoW ! Thank you! Just what I was looking for…I’ll try it and post progress afterward.
Thanks !

Hi Cotaks, thanks for your input. Yes…I understand that, and I was trying to move(update) the background origin each time as the W, S, keys are pressed. But didn’t work.

Hi I finished making an example of a gyroscope - here is a file for UPBGE version 0.2.4, another tip you will have to move the cockpits (cabins) of aircraft to another scene and add it by overlapping to the game scene-I hope my example is also useful :slightly_smiling_face:Hiroscope.blend (129.5 KB)

WoW…! What a great example for me to study. I’ll have to figure out how to adapt this to my attitude gyro indicator.
Thank you so much, Viktor!
I’ll post a demo of my gyro when it’s done.
Thanks again.

as I wrote before do a second scene with the cockpits for the aircraft and add it to your game scene - so it will be easier to control your game and your cabin will never overlap objects from the game and force the speed and dynamic of the collision will not affect the instruments in the cockpit, even more quietly to forge some instruments and their work, and the player won’t notice - then it will be 100% flying the plane :slightly_smiling_face: good luck :+1:

Hi Viktor…Thanks for the great little Hiroscope !
I was studying your model and noticed the gyro ball rotates in reverse ---- it points to ground (brown) when aircraft pitches up and points to sky (blue) when aircraft pitches down towards ground. Is this how you intended it to be?
Click here for demo

Also, is the hiroscope.hiro module part of UPBGE module library ?


Thanks for your help.

Hi! to reverse the display, you either need to scale the gyroscope along the Z axis or add a dummy object that you just need to flip and assign for tracking in the script instead of the map, the hiroscope module.hiro is not part of UPBGE I quickly wrote it for the orientation of the gyroscope ball - this script just copies the orientation of the map