Mission Area Player Clip / Bounds & Manual Bounding Box
by 000 · 08/27/2012 (10:05 pm) · 8 comments
This resource is based on Leslie Young and Britton LaRoches work (and it should be noted that Michael Hall has a similar resource), taking those concepts it further dilutes them to a basic bounds that will block the players movement when they travel outside the mission area.
Instructions:
Make sure Torque 3D is closed.
In /server/scripts/player.cs add in the 'forcing player away' code:
Save the file.
Launch T3D, now open your level and under Library/Level/Level add a Mission Area.
In the Mission Area editor place your Mission Area (you may have to reset it's coordinates to 0 0 0 512 so it shows up in the editor). Make sure your player is in the Mission Area.
Save your map and exit Torque 3D.
Open your map in Torsion or WordPad and locate "new MissionArea"
Change the following on it:
Change new MissionArea() { to new MissionArea(GlobalMissionArea) {
Add:
bounce = "5"
enabled = "1"
So it looks sorta like this:
You can adjust the 'bounce' factor and really push the player around if you like. I find "5" is just enough to stop the player in it's tracks.
From what I can tell this won't work on vehicles, check the referenced resources above, they talk about it a little. I'm not sure if it'll keep AI out.
On the smaller and more manually placed scale I've been using a bounding box with some success. I've uploaded it to here (right click, save) for anyone to download. You can adjust the height and length but not the width, as soon as you change the width beyond "1" then the player can walk right through it. Not an ideal solution (I would prefer a form of trigger) but it does what needs to be done.
Hope this help and let me know if I'm out to lunch on somethings and I'll adjust the resource.
Instructions:
Make sure Torque 3D is closed.
In /server/scripts/player.cs add in the 'forcing player away' code:
function Armor::onLeaveMissionArea(%this, %obj)
{
//echo("c4Leaving Mission Area at POS:"@ %obj.getPosition());
// Inform the client
%obj.client.onLeaveMissionArea();
// Damage over time and kill the coward!
//%obj.setDamageDt(0.2, "MissionAreaDamage");
// Start: forcing player away code <--- THIS IS WHAT WE'RE ADDING
%force = GlobalMissionArea.bounce;
%min_x = getWord(GlobalMissionArea.area, 0);
%min_y = getWord(GlobalMissionArea.area, 1);
%max_x = %min_x + getWord(GlobalMissionArea.area, 2);
%max_y = %min_y + getWord(GlobalMissionArea.area, 3);
%x = getWord(%obj.getPosition(), 0);
%y = getWord(%obj.getPosition(), 1);
%vx = 0;%vy = 0;%vz = 0;
if (%x<(%min_x+10)) %vx = %force;
if (%y<(%min_y+10)) %vy = %force;
if (%x>(%max_x-10)) %vx = -%force;
if (%y>(%max_y-10)) %vy = -%force;
%vec = %vx @ " " @ %vy @ " " @ %vz;
%obj.setVelocity(%vec);
// End: forcing player away code <--- END OF WHAT WE'RE ADDING!
}Save the file.
Launch T3D, now open your level and under Library/Level/Level add a Mission Area.
In the Mission Area editor place your Mission Area (you may have to reset it's coordinates to 0 0 0 512 so it shows up in the editor). Make sure your player is in the Mission Area.
Save your map and exit Torque 3D.
Open your map in Torsion or WordPad and locate "new MissionArea"
Change the following on it:
Change new MissionArea() { to new MissionArea(GlobalMissionArea) {
Add:
bounce = "5"
enabled = "1"
So it looks sorta like this:
new MissionArea(GlobalMissionArea) {
area = "0 -40 200 512";
flightCeiling = "2000";
flightCeilingRange = "50";
locked = "1";
canSave = "1";
canSaveDynamicFields = "1";
bounce = "5";
enabled = "1";
};Save the file and load up your map. When your player hits the Mission Area bounds they should stop cold.You can adjust the 'bounce' factor and really push the player around if you like. I find "5" is just enough to stop the player in it's tracks.
From what I can tell this won't work on vehicles, check the referenced resources above, they talk about it a little. I'm not sure if it'll keep AI out.
On the smaller and more manually placed scale I've been using a bounding box with some success. I've uploaded it to here (right click, save) for anyone to download. You can adjust the height and length but not the width, as soon as you change the width beyond "1" then the player can walk right through it. Not an ideal solution (I would prefer a form of trigger) but it does what needs to be done.
Hope this help and let me know if I'm out to lunch on somethings and I'll adjust the resource.
About the author
#2
Alternatively you could change the message to say whatever you'd like but note that it spams the message a bit if the player is constantly smacking the bounds area.
I've uploaded a test map with a Mission Area already applied, it can be downloaded here (right click, save). When you try to move past the lights you should stop.
08/28/2012 (6:40 am)
When you hit the Mission Area bounds you'll receive a 'leaving Mission Area/entering Mission Area' message. If you want to remove this message or change it to something else then it's located in scripts\server\game.cs, I simply commented it out to remove it:function GameConnection::onLeaveMissionArea(%this)
{
// The control objects invoke this method when they
// move out of the mission area.
// messageClient(%this, 'MsgClientJoin', '\c2Now leaving the mission area!');
}
function GameConnection::onEnterMissionArea(%this)
{
// The control objects invoke this method when they
// move back into the mission area.
// messageClient(%this, 'MsgClientJoin', '\c2Now entering the mission area.');
}Alternatively you could change the message to say whatever you'd like but note that it spams the message a bit if the player is constantly smacking the bounds area.
I've uploaded a test map with a Mission Area already applied, it can be downloaded here (right click, save). When you try to move past the lights you should stop.
Quote:Konrad: Many thanks for sharing it!No problem, hope it helps!
#3
Just read the bottom half - doh! :) I'll have a go at this and see if I can adapt it to support vehicles.
08/28/2012 (12:20 pm)
nice work Mack - does it work for vehicles?Just read the bottom half - doh! :) I'll have a go at this and see if I can adapt it to support vehicles.
#4
Thanks S2P, it's just my assumption it won't work for vehicles as the other resources said it wouldn't. I'm assuming that if you took the same function Armor::onLeaveMissionArea(%this, %obj) function with the 'forcing player away code' and applied it to your vehicle class then it would repel the vehicle as well, but that's just pure speculation.
08/28/2012 (2:58 pm)
Quote:S2P: nice work Mack - does it work for vehicles? Just read the bottom half - doh! :) I'll have a go at this and see if I can adapt it to support vehicles.
Thanks S2P, it's just my assumption it won't work for vehicles as the other resources said it wouldn't. I'm assuming that if you took the same function Armor::onLeaveMissionArea(%this, %obj) function with the 'forcing player away code' and applied it to your vehicle class then it would repel the vehicle as well, but that's just pure speculation.
#5
08/30/2012 (3:08 am)
Thanks Mack, very usefull !
#6
Critically important: As I've been using this resource for my maps I noticed that there was a problem with manually text editing the mission where it would corrupt the MissionGroup and make the map unloadable (but not unsalvageable).
I'm going to recommend editing the Mission Area within the editor itself, you can set the name of the Mission Area to GlobalMissionArea and add the bounce = 5 in the dynamic fields. If anyone needs assistance drop me a line.
08/31/2012 (11:38 pm)
I can't edit this resource properly due to the site bug with the quotes and what not.Critically important: As I've been using this resource for my maps I noticed that there was a problem with manually text editing the mission where it would corrupt the MissionGroup and make the map unloadable (but not unsalvageable).
I'm going to recommend editing the Mission Area within the editor itself, you can set the name of the Mission Area to GlobalMissionArea and add the bounce = 5 in the dynamic fields. If anyone needs assistance drop me a line.
#7
Thanks Mack, very usefull !
The code display is not normal ?
09/04/2012 (12:36 am)
Excellent resource!Thanks Mack, very usefull !
The code display is not normal ?
if (%x<(%min_x+10))
%vx = %force;
if (%y<(%min_y+10))
%vy = %force;
if (%x>(%max_x-10))
%vx = -%force;
if (%y>(%max_y-10))
%vy = -%force;
#8
When I get there, I'll try working it into vehicles and post back.
09/27/2012 (12:12 pm)
Perfect timing, one that's on my to-do list.When I get there, I'll try working it into vehicles and post back.

Associate Konrad Kiss
Bitgap Games
Many thanks for sharing it!