Notifications
Clear all

[Closed] Problem with Script Controller

Hello

I have a small problem with a Script controller which has been puzzling me for a couple of days now.

I am trying to setup some automation on some Airplane wing flaps. These flaps will be rotated appropriatly just before the actual body of the
plane is rotated but based on the bodies rotation. I am using a script controller to control the flaps. However I have a couple of strange results
which I cannot figure out why.

This is the script as it is seen in the controller. I have also attached the scene file.

at time f
myDiff = MyfutureRot – MyPastRot
print mydiff
at time (F + 2)
((((myCurrentRot)* MyDiff) / 150) * -1)

v: T:0
v: S:0
v: F:0
v: NT:0
v: Body:0
v: MyPastRot:-160 – This is lined to the Body Y rotation – 1 Frame
v: MyFutureRot:160 – This is lined to the Body Y rotation + 1 Frame
v: MyCurrentRot:0 – This is lined to the Body Y rotation at current frame

Now the script is designed to straighten the flaps if the plane has not been rotated in a certain number of frames. This is to simulate the fact the flaps only move when ther plane
is actualy turning and not when it has turned. So to do this I find the difference in the future and past rotations and multiply the flaps rotation by the difference so that when the plane is not rotating
the difference is close to zero and flap does not move. However there is a slight problem. The flap seems to move OK some times and not others!!
This is a little confusing. If this has a simple answer please forgive me as my maths is rather poor. both flaps use the same script with the exception of the -1 multiplier to reverse the action.

Any help would be appreciated

Thanks

Harry

Scene Created in MAX 9

8 Replies

Been trying this again when I got home this evening and I cannot figure out what is causing this odd behaviour. If any one has any Idea’s that would be great.

Thanks
H

 PEN

This could be a rotation issue not your script. Are you flying the plane around in the circle? If so then you are seeing rotation problems. The plane is sitting in world space, there is no such thing as local. So the axis down the body of the plane would be changing all the time as it flies around in a circle.

Is this the cause of your head aches?

Hi PEN

The plane is still just a test object at the moment. It is simply being rotated o the y axis. It isnt moving at all!

Harry

Oops Double Post somehow!! Please ignore.

Hi PEN

The plane is still just a test object at the moment. It is simply being rotated on the y axis. It isnt moving at all!

Harry

 PEN

Hmm, I would have to look at it then.

Hi PEN

I would appreciate it. But no pressure I know you are busy, ive just pulled a rather long day too.

. Now im off to bed…

Thanks

Harry

 rdg

Hi Harry,

I think the problem is the (missing ?) accumulation of rotations in your script.
You just check for the difference between past and future.

I haven’t testest this, but I would start as such:

In the init section (F==0) declare a variable like banking = 0.
Also connect a banking_max to a customAttribute.

Get the rotation_offset to past (= abs(now – past))
Get The rotation offset to futute (= abs(future – now))
Now add 1 or more to banking for rotation in the future and subtract 1 or more for rotation in the past from banking (?). This should kind of average the banking over time.
Also if no rotation happens subtract 1 from the banking to get it to zero over time.

Then you can interpolate between the current and the max banking value and feed this into the flaps.

As I said this is just a rough layout. I would probably need more variables, maybe less.
Maybe you need to distinguish between the two flaps or left and right. Also the adding/subtracting is just a guessing.

But be generous with variables and tests in the beginning and as soon as it is working you can straighten the code. And maybe a lot of them falls way.

Georg

Hi Georg

That makes sense.

So you dont think me ignorant, I have just been dragged off that project and onto another “more urgent! ” one. But will have a look into this again once I have completed this, hopefully at the end of the week.

Thanks very much for yours and PENs help so far.

Thanks

Harry