Constraining "track to" to a single axis....


(LukeW) #1

I’d like to make tree sprites that rotate around the vertical Z axis to face the camera - but don’t tilt to the side or tilt up and down. If I used “Track To” the tree would tilt I think.
Theeth made a tracking script in the python forum, but I was wondering if there is a way to avoid using scripts because I’d like to use hundreds of trees and scripts might slow down the framerate quite a bit.


(theeth) #2

In the next update of my script, the tracking rotations will be written in IPOs, so you will only have to run the script once for every object and the IPOs will do the job the rest of the time.
There’s a way to do it without a script, but it only works for tracking restricted to basic global axis (X, Y, Z): http://www.elysiun.com/forum/viewtopic.php?p=58972

Martin


(S68) #3

If you use a Copy Rotation constrain to the camera?

Stefano


(LukeW) #4

S68:
Unfortunately I can’t get it to copy just the vertical Z rotation and not the X and Y rotations… “Copy Rotation” copies the whole rotation. But otherwise that method is a good one for making certain kinds of sprites - e.g. spherical-type ones. (Though maybe blender has a built-in way of creating spherical-type sprites - e.g. like the ones used in particles)

theeth:
Thanks for that link about doing it without a script… it seems that it only works properly when the turret is at the origin of the axes.
About your planned update of the script - what happens if you create IPO’s with the script and then you move the turret or the empty somewhere (i.e. you change your mind) - would it be easy to recalculate the IPO’s? Does the IPO generator script for the turret have any advantages besides possibly speeding up rendering times? I guess you could delete the empty once you’ve created the IPO’s, but on the other hand it is good to have the empty there just in case you want to adjust the animation. I don’t really see the point of creating IPO’s for the parts of the turret as opposed to only animating the empty it tracks and calculating the orientation of the turret in real-time.
Like alltaken in that thread link you gave, I’d like to also request you try and make a script that lets you have a turret that can move around - e.g. like a tank on hilly terrain… (and I don’t think calculating IPO’s with the script are necessary in order to do that) Thanks…


(theeth) #5

uhm… I just checked back and it works even if the turret is not centered. In fact, if you try moving the turret, you’ll see the tracking update in realtime.

you’d just have to rerun the script for that particular object.

It’s particles compatible. That is, if you parent a particles system to the canon, it will update according to the motion, unlike the linked script that calculates in real time.

I just tried something and this can easily be done using the IPO version of the script and a Copy Loc constraint.

Martin


(LukeW) #6

Well it works properly if you move the turret’s base around the XY plane, but not if you move it up and down. BTW, I’m using Blender 2.23. It is strange because “Track_Loc” is meant to copy the Z location of the turret… but it is red for some reason. It is supposed to copy the Z value of “Cube”… if I change this to “Tube” it is no longer red, but “Track_Loc” doesn’t move up and down. So there are some very weird problems.

I just tried something and this [tanks moving on hilly terrain] can easily be done using the IPO version of the script and a Copy Loc constraint.

I hope to see a demo blend file sometime… Thanks.


(theeth) #7

Well it works properly if you move the turret’s base around the XY plane, but not if you move it up and down. BTW, I’m using Blender 2.23. It is strange because “Track_Loc” is meant to copy the Z location of the turret… but it is red for some reason. It is supposed to copy the Z value of “Cube”… if I change this to “Tube” it is no longer red, but “Track_Loc” doesn’t move up and down. So there are some very weird problems.[/quote]

oh, yeah, I forgot to mention that you have to apply the fix I mentioned in the thread (that is, deleting that constraint and parenting the Empty to the base) in order to do that.

Martin


(LukeW) #8

Thanks theeth…
For people who want to download theeth’s scriptless turret tracking demo, I made a cleaned up version here. (I got rid of most of the unnecessary parts, and made it easy to distinguish the top of the turret from its bottom)
If you move the camera around, the text will always face the camera - I used S68’s “Copy Rotation” idea… I’ll probably use that technique in the future - I’d have words moving through 3d space, always facing the camera, but sometimes behind or sometimes in front of 3d objects… so it would be a bit surreal.