Game Development Community

dev|Pro Game Development Curriculum

Trigger not work (temporary fix)

by D Fasel · 02/24/2014 (4:55 am) · 17 comments

Hi all, i think i will show you, how i got fixed that trigger problem. I know some engine fixes are around. I try out all this fixes, but the triggers get not really fixed by this engine bug fix. Here my temporary solution for the problem with the trigger.
---------------------------------------------------------------------------------------------------------

I had 2 days to find a way to solve that trigger problem.
As first i find out, that when i make an new polyhedron with other numbers, that the trigger work, as long i don't quit the game. But after new start of the game, the trigger not work. So i got the idea, that some problems happens with the trigger, after mission start.

This let me think to make a solution, where all trigger get a new polyhedron, some seconds after the mission is start.

As first do the engine trigger fix !!!

Now use the following scripts.

Put this script to server/gameCore.cs at the end of function GameCore::startGame(%game) :

%game.schedule(8000,BUGFIX1); (8000 = 8 second)

Then put in the following function after the GameCore::startGame(%game) function :

//-------------------------- This is here to fix a problem with the triggers
function GameCore::BUGFIX1(%game)
{
// !!!! all trigger must be in an folder, named Triggers !!!!
%dataGroup = "Triggers";
%triggerCount = 0;
echo("T R I G G E R ------>BUGFIX 1");
for(%i = 0; %i < %dataGroup.getCount(); %i++)
{
%obj = %dataGroup.getObject(%i);
if(%obj.getClassName() !$= "Trigger")
{
// no trigger!
continue;
}

echo(%i SPC "Found Trigger:" SPC %obj.getName());
%triggerCount++;
// NOW we just change the size of the polyhedron and then we change it back (this let the trigger work again)
%obj.polyhedron = "-0.6000000 0.6000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
%obj.polyhedron = "-0.5000000 0.5000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";

}
}
/////////////////////////////////////////////////////////

not sure everyone get this trigger problem, but i can set up a fresh t3d and the trigger problem just is here. I did make the engine bug fix also.
Hope this trigger problem get soon fixed. it must be a problem with the polyhedron and mission start sequence. maybe a timing problem? dunno.. but try out my fix, if you get problems with triggers.

About the author

Working in the team of Winterleaf Entertainment as an Lead Level Designer and Environmental Artist. Selling content and art packs ready for T3D at my shop www.game3d.ch/shop


#1
02/24/2014 (5:15 am)
What exactly is the trigger problem? I'm not having any in my 3.5 base... Do they fail to fire or is there a delay?
#2
02/24/2014 (5:33 am)
All my triggers just don't work. This mean if the player enter the trigger, noting happens. Except i use this fix i made.
This happens in all my fresh set ups of t3d and also in the older projects i made. I only have this trigger problem with the latest t3d version.

When i change the polyhedron to this :-0.6000000 0.6000000 .........
while the bug happens. the trigger work, but after new start of the game it work not. Except i change the polyhedron again.

The only way it works, if i use the fix above.
#3
02/24/2014 (7:34 am)
Think it might be the character? Care to try it with one of my character rigs? I have not seen this yet. search Shoiko at turbosquid and download either they are T3d ready
#4
02/24/2014 (7:45 am)
No, is not the character. I try out many different ones, also the soldier.

it must be some thing while mission start, so the triggers get broke. the only solution is to change the polyhedron, like it does in my fix. And also after some seconds the mission is loaded. I'm pretty sure it have some thing to do with the mission start and triggers. How i said, i had 2 days to find a solution and doing tests to find out that it must be after the mission is load, or while the game is loading.

At least i can live with my fix is just a bit more script and i have to put all triggers in an trigger folder. That's not a big thing to do.

The only weird thing is, that it seems that this bug only happens at me.
I also try out a fresh installation of version 3.5 with no changes only the engine bug fix for the triggers i was doing. The same trigger problem happens also in a fresh installation.
#5
02/24/2014 (7:53 am)
I'm I'm going to do testing in my full template when I get home I use triggers for several things. Thanks for the info
#6
02/24/2014 (7:59 am)
Yea, triggers are much used in games:) One thing i don't try out was to reinstall the dx sdk. maybe there is the problem.... i will test this also, in the next days.
#7
02/24/2014 (2:19 pm)
This was already mentioned about in another post, here's the engine fix to fix triggers (working for me now):


in T3D/Trigger.cpp
Find ConsoleGetType(TypeTriggerPolyhedron)

// Build output string.
	char* retBuf = Con::getReturnBuffer(1024);
	dSprintf(retBuf, 1023, "%7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f",
	         origin.x, origin.y, origin.z,
	         vecs[0].x, vecs[0].y, vecs[0].z,
	         //vecs[1].x, vecs[1].y, vecs[1].z,  // Jeff: reverted to Torque3D MIT 3.0, as this broke T3D MIT 3.5 Triggers
	         //vecs[2].x, vecs[2].y, vecs[2].z);
			 vecs[2].x, vecs[2].y, vecs[2].z,
			 vecs[1].x, vecs[1].y, vecs[1].z);
#8
02/24/2014 (2:29 pm)
I did use that fix! But the triggers don't work, except I use my fix.
#9
02/24/2014 (3:25 pm)
Hmm, maybe mine works because I'm using physX and rewrote part of the code for physX :P
#10
02/25/2014 (12:41 am)
Have you checked your mission files. It seems that in some cases the trigger datablock is not saved in the triggers, which causes them not to work.
#11
02/25/2014 (12:58 am)
I have checked this too, I think I have checked everything, outside the engine source. The data blocks are ok. Also the scripts for the triggers work well. The problem is more about the collision detect between the polyhedron and the object enter the trigger. I don't had any trigger problems before version 3.5. This only happens in version 3.5.

If the trigger don't work and I change the polyhedron like i told, the trigger work as long I don't put in new triggers or restart the game.

This gave me the idea to put all triggers in a folder and just do the polyhedron change to every trigger after the mission has start. This let all trigger work. Dunno why this happens, and why it works after changing the polyhedron.
#12
02/27/2014 (6:08 pm)
also, another alternative method that is somewhat less hacky is to just set the polyhedron in

function my_trigger_Datablock::onAdd(%this, %trigger) {

}
#13
02/27/2014 (6:48 pm)
The idea is good, but don't solve the problem. That's why i made the delay after mission start, before the function change the polyhedron. The delay of some seconds must be. If not, some triggers work some not.

I also find out more weird things, happens. When I use the setHidden function , let's say to make some objects temporary inactive, then after mission start some are not hidden, some are. if i open the editor, all go hidden. Same thing happens if i want that they are visible at start of a mission. It seems this function work only right, if I open the editor.

In some case i feel that the trigger problem and this with the setHidden function have some thing to do together.
#14
03/02/2014 (2:56 pm)
maybe is an issue with modifying the stock triggers and saving it properly to the mission files?

had mine drop out of the mission file at odd times after making changes.

But I just tested in a 3.5 build, created a new mission and added a trigger ... to validate its working, I added an echo statement on enter and exit of the trigger.

and it saved properly, was there when i reloaded mission ... and works when I enter or leave the trigger area.
#15
03/02/2014 (9:27 pm)
All triggers are proper saved in the mission file.
#16
03/03/2014 (12:57 pm)
Good news! Find out why the triggers got bad.
How I told, I don't test to update my DX. Now today i did update DX11 on my pc, and voila, the triggers work without to need my hacky fix :)

But the engine fix must be! Without the triggers don't work.

At least, my fix can be used to show, how we can delay a function after mission start, and how we can scan a system folder and change things at the object in the folder.

Oh, and if you get weird bugs like i had here, a DX11 update maybe helps ... :)

#17
07/20/2014 (6:36 pm)
To my last post here: Sorry, this was not the solution about the trigger problem.