using hprInterval to make two nodes hpr settings match

I am trying to simulate an “auto-pilot” style function in my flying spaceship that will cause the ship to slowly rotate around to face opposite of it’s current direction of travel, then fire the engines until it stops in space.

I was planing on using hprInterval to do the rotation.

In order to make this work, I create 2 nodes at the ship’s current position. one parented to the ship, the other parented to render so it stops moving. I let the scene redraw a few times, then set the second temp node to lookAt(firstTempNode). Then, I use this line:


(tempShipNode is the one that is looking at the node that was at the ships previous location.)

If I use setHpr rather than hprInterval, it works fine, just doesn’t rotate in a natural looking method. Any ideas why the interval isn’t working out?

Also, if there is a better way, using a vector or something, I would love to hear about it.

For what it is worth, here is the code:

self.tempFacingNode = render.attachNewNode("tempFacingNode")

Then, I run a task that executes 5 times, so there is time to get some distance between the two nodes. Then I use:


The wrtReparentTo is to get the node into render’s coordinate system instead of the ship’s.

Like I say, if I use:


Instead of the hprinterval, it works, but jumps rather than rotating nicely.

Any thoughts?

Thank you so much for any assistance!

edit: fix spelling error

OK, trying again:

When the game starts, my heading is -90, p=0, r=0

print self.ship.getQuat().getForward()

results in:


I have an event handler keybound that calls my routine. Print statements verify that the event handler works.

Here is what is in the handler:


This turns my ship from a heading of -90 to a heading or 90, rotating me 180 degrees.

If I change it to


Nothing happens. No errors, it just does not rotate as I would expect.

-Please-! I am trying to understand what I am doing wrong here. Even if the hprInterval seems to interpret the parameters differently than setHpr, it should at a mimimum rotate 90 degrees, shouldn’t it? Why is the interval not iterating?

The command:


Doesn’t do anything by itself. All it does is create and return an interval, which you are ignoring. You need to play the interval:

i = self.ship.hprInterval(5,myVector) 


Thank you! I had almost gotten there.

I had found the i = self.ship…

But hadn’t gotten to the i.start(), as my only other usage was calling .loop() instead.

Thanks again!