# Limit object rotation using actuators in python

hey guys, i have been working on a python script for a game i am working on. I am trying to make an AI’s rotation limited by the motion actuators that the script has been assigned to control. can you help me?

-AJ

This depends on what exactly you mean.

AI is just another word for “behavior” and has usually nothing to do with rotation.

You should also specify what limits (values, directions etc.) on what rotation (axis) you mean.

A quick sketch might help.

mayble you need to orient the obj in a certain direction?
thats is easy with python

can using (the brother) getVectTo() / alignAxisToVect()

this no problem

well by AI it’s using a edit object/track to actuator so i want it to follow the rotation i have set for it with other motion actuators. If you would like i can post up the blender file.

This (partly) explains how you want to implement your idea. But this does not tell what the idea is ;).

oh oops…anyway here is the idea.

My idea is for airplanes.Most airplanes can’t turn on a dime right? So that’s why I have set up a few motion actuators for the AI to obey. Think of it like this; if an airplane were to fly like a helicopter, it would crash because a airplane cannot turn on a dime due to the speed it is going at right?

So my idea is to use a python script to tell the AI airplane to look at the motion actuators in order to track to the players airplane using the motions in the motion actuator Hope this helps clear it up a little better.

So you mean the plane should have a turning circle?

With that it makes more sense to ask for a rotation limit.
I think you need to combine the forward motion with the turning direction. It can be in a way that when standing still the plane does not turn at all.

Usually a turning car for example turns because of one axis provides a forward force while another axis provides a side motion (not necessarily 90°).

A plane is similar. The air at the stabilizers create a force on the border of the plane to make the plane rotate. The strength of the force depends on the forward speed of the plane.

You can do the same. Apply a forward force. Then read the forward speed from linearVelocity (local forward axis). Then apply a side force calculated from the forward speed and whatever steering vector.

I think you need some Python for it.

If you plane goes constant speed you can simply use any rotation you like as long as the there is any speed.

You can also do a search for airplane physics. It is asked from time to time.

I hope it helps you a bit

ok, so you’re saying i need to get the linear velocity from the owning object in order to limit it’s rotation. hm…how would i script that?

to get the linear velocity
global:
vel = own.worldLinearVelocity (warning linearVelocity is LOCAL , is a error)

local
vel = own.localLinearVelocity

for the rest cannot help…