Game Development Community

Using Triggers to change direction

by Louis Dufresne · in Torque Game Engine · 01/22/2005 (7:23 pm) · 10 replies

Im trying to setup triggers so that when a player enters it will just send them in the opposite direction. Anyone know a good way to do this? Should I use a physical zone instead?

thanks

#1
01/22/2005 (8:13 pm)
A trigger probably would work.. just have it so when you enter it it will turn you in whatever direction you choose.. I think getpos.. or something..
I am no coder but i am sure you could set it up so it spins you on the Z axis in the opposite direction..
#2
01/22/2005 (8:38 pm)
What sort of effect are you looking for? Player faces in opposite direction? Player gets bounced back? Both?

A trigger sounds like the right way to go. Your effect code will be in the onentertrigger method. To bounce the player back, use applyimpulse. To turn the player around, use settransform.
#3
01/23/2005 (7:17 am)
Im trying to make some bounds or barriers in mid air. So when the player slides into them they would then sort of bounce him back in the opposite direction.

I will try the applyimpulse and see where I can get with that. Thanks
#4
01/23/2005 (7:50 am)
Is there a way to test for player direction? If he is facing forward but is sliding left or right is there a way to test for left and right?

I want to test sliding and just make it so when he enters the trigger it slides him the opposite way.
#5
01/23/2005 (10:25 am)
I'm hesitant to post here because this is definitely not an area of expertise for me, but I think velocity is a vector, and can be treated as such. If that is the case, you should be able to take the player's current movement vector and simply invert it via vector/scalar math and apply a scaled down version of it back at the player...

Anyone with more experience in this type of thing have a confirmation/correction?
#6
01/23/2005 (4:42 pm)
Looks like the other users of that resource are also looking for the same thing as you :)

There is a problem, though, with putting that link here. This is a public forum, and you are providing the public with access to Torque source code. Since this problem now involves Torque source code, there are two things you should do:

1) Delete your post that points to Torque code (2 of them since you double-posted). Just click on the little picture of a trashcan at the top of each post.

2) Create a new thread for this topic in the Torque SDK private forum. Make sure that your new thread has a link to this thread so that everyone can see the history of your problem. One possibility for new thread title is "mission area forcefield for vehicles."
#7
01/24/2005 (1:27 am)
Well - if I recall correctly there is actually a resource that lets you (in script) bounce the player off the mission boundary.

So its public, its possible in script only and its quite easy to do actually using triggers instead of the mission boundary (the concept is the same)
#8
01/24/2005 (1:35 am)
See the last post here, this seems to have the desired effect without the triggers.
#9
01/24/2005 (7:06 am)
Well the good news so far is that I have it so the vehicles colliding with the misson area works to the point where it will change it to an orange color. Now I am working on getting the vehicle to bounce backwards.

This took some working in the code to do. I will let you all know when I have it totally figured out.



I got it working with the flying vehicle. I will put up a resource for it in a little bit!

#10
01/28/2005 (9:13 am)
Here is the link to the resource that takes care of flying vehicles and mission area bounds:

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7051