Author Topic: Placing a trigger around an object  (Read 2402 times)

How can I place a trigger around an object? Since bricks don't have oncollision, I want to make a trigger so I know when a client touches it. I know how to spawn the trigger around the brick etc, but I want to make the trigger as wide as the brick. How can I do it (if I can)?

.....Example script, obviously won't work since it's just off the top of my head, but you'll get the idea
Code: [Select]
function createdoortrigger(%brick, %owner) {
if(!isobject(%brick)) return;
%position = %brick.getboxcenter();
%trigger = new trigger() {
datablock = BrickDoorTrigger1;
owner = %owner;
}
%trigger.settransform(%position);
%trigger.setscale(%brick.getworldscale());
}

%trigger.setscale(%brick.getworldscale()); didn't work, which was basically the point of what I needed. :|

.....Example script, obviously won't work since it's just off the top of my head, but you'll get the idea

All I need is a function to set the trigger's size to that of the brick and maybe a bit more.

Make a 1x1x1 brick, make a trigger, resize it to fix aroudn the brick, make a script that calculates off the scaling as a base. A trigger is about 2x2x2 brick size, but you'll need some fine adjustments to make it perfectly around it

Bricks don't get scaled in Retail, so it'll always say "1 1 1" which means the trigger will always be 1 1 1. You need to do something like this:

Code: [Select]
%triggerX = %brick.dataBlock.brickSizeX/2;
%triggerY = %brick.dataBlock.brickSizeY/2;
%triggerZ = %brick.dataBlock.brickSizeZ*0.2;
%trigger.setScale(%triggerX SPC %triggerY SPC %triggerZ);
%trigger.setTransform(%brick.getTransform());

That will do it. If it needs to be a tiny bit bigger, try this:

Code: [Select]
%triggerX = (%brick.dataBlock.brickSizeX+0.2)/2;
%triggerY = (%brick.dataBlock.brickSizeY+0.2)/2;
%triggerZ = (%brick.dataBlock.brickSizeZ+0.3)*0.2;
%trigger.setScale(%triggerX SPC %triggerY SPC %triggerZ);
%trigger.setTransform(%brick.getTransform());

But I didn't try the last one, should work though.
« Last Edit: April 09, 2007, 05:18:53 PM by Ephialtes »

Great! Just one thing - it sets the trigger's corner to the center of the brick, thus making it 1/4 on the brick...any way around this?

An offset?

Of course I fail at scripting =)

move it 0.5 units right and down then. or left and down. whatever.

...figured this out a while ago, used it in my racing mod. :P