triggers

hello

maybe its a dispensable question … but is it possible to use triggers in animations … for example if a mesh passes an trigger and another mesh reacts with that ? is it possible ? yes ? no? maybe ? :slight_smile:

thanks for helping

Yes, but this is one of Blender’s harder concepts. Search for “IPO driver” and any post by Fligh or Hazard on the subject should be required reading. And I guess the wiki and blender.org site documentation. :slight_smile:

You can set a collision, near, radar or touch Sensor in the GameEngine and use Write IPO (“Game” in the top header, “Record Physics to IPO”) to record rendertime IPO’s. Otherwise you can use the Influence IPO of a Constraint to ‘grab’ or ‘release’ an object, BUT, it’s not possible to base it off proximity and you’ll have to Keyframe all of it anyway. How good are you at Python or C++?

%<

I used a proximity of sorts for a telescoping antenna.

My script calculated the distance between an Empty that would be the hand/fingers pulling the end of the antenna, and the base of the antenna.

As the distance grew, another Empty was translated via the script up it’s z-axis, the animation of the antenna parts was driven by that same Empty’s z-axis, and it worked great.

I just tried to make a proximity trigger using the same concept but I am not getting the same results for some reason.

If I get it worked out I will let you know, it should be pretty simple.

I found out what the problem was.

In my telescoping antenna: http://hdiss.net/bpeters/ContraintsTestScripted.blend

The ‘Hand’ distance from ‘BaseEmpty’ gives ‘slider’ it’s z value, which drives the IPO of ‘TipEmpty’.
‘TipEmpty’ is a child of ‘BaseEmpty’
‘BaseEmpty’ has a ‘track to’ constraint tracking ‘Hand’

The script will always give ‘slider’ it’s z value based on the criteria above, but for some reason it will only drive an IPO of an object that is linked in some way to ‘Hand’.

‘Hand’ being the object that is calling the script via a link set to ‘redraw’ for live action without scrubbing the time slider.

From what I have learned so far, this link can be direct or inherited.
‘BaseEmpty’ could have an IPO driven by ‘slider’(the object affected by the script called by ‘Hand’).
A child of ‘BaseEmpty’ can also have an IPO driven by ‘slider’.

This link requirement seems to be only needed to view the results live via calling the script on ‘redraw’ as opposed to ‘frame changed’.

In my proximity test: http://hdiss.net/bpeters/ProximityTest.blend

I have: Cube, Sphere, Empty, Empty.001, Circle

The Sphere has IPO’s to make it shake around, IPO’s are cyclic extrapolate
Empty.001 is parent of Sphere and has ‘track to’ constraint tracking Cube.
Cube calls the script via link set for ‘redraw’.
Empty drives the IPO’s of Sphere.
The Circle is used as a visual aid of the trigger distance in 2D looking down(numpad 7)
The script calculates the distance between Cube and Sphere.
It also reads the Scale/Size X of Circle and uses that as the distance of the trigger, when Cube gets inside the Circle, Sphere get a little shaky :slight_smile:
When Cube is inside Circle, the script adds 1 to the z location of Empty on every redraw, or if you are running animation it would be every frame as long as Cube was inside Circle.
When Cube exits Circle, Empty’s z locaton is reset to zero just as a precaution so we don’t send Empty to the moon.
The reason for Empty.001 being parent of Sphere was just that is what I did last, you can delete Empty.001, and link Sphere in some way(track to constraint?) to the object calling the script, Cube.

Try clearing the parent from Sphere and moving the Cube close, you will see nothing happen, unless you animate the Cube moving into the Circle and play the animation, then you will see the Sphere shake.

Also something to think about is that if the object that is to set the trigger being translated as a child of something else, like a path(follow path), it’s location read by the script will never change, thus never enter the trigger zone.

Try parenting the Cube to something just outside the Circle, then rotate the new parent of the Cube to move it into the Circle, you will see nothing happen.

Hope this wasn’t too confusing, play around with it, see what you can make of it.

Here is a way to link the animated object to the triggering object without causing unwanted movement of a ‘track to’, if you want to be able to view the action without running the animation.

Place an Empty somewhere, add a constraint to your animated object to ‘copy scale’ of the Empty.
Then add a constraint to the Empty using the triggering object, ie. ‘track to’, ‘copy rotation’, etc. , something that won’t affect the Empty’s scale. That completes the link necessary.

Happy Blending! :slight_smile:

Work sure gets in the way of a good time :frowning:

This took me a while and required the use of a brand new Python module, but I created a first version of a proximity trigger script, well that script was easy, but getting the GUI built took the time.

This was started with Blender 2.42RC3 but finished up with the release of 2.42, and with a full install of Python 2.4.

http://hdiss.net/bpeters/ProximityTrigger.blend

Give it a try, like I said it is first version, don’t be soft, if it’s a waste of time let me know, I had fun creating it and probably expand on it just for the heck of it.

p.s. if you get an error trying to run the GUI script saying blender can’t import module ‘Constraint’ your blender version is not new enough.