What does the Mission Area do?
by Jacob · in Torque Game Engine · 12/16/2004 (6:46 pm) · 14 replies
I want to restrict the player from going outside of the mission area, especially that the terrian repeats itself. Do I have to build a collision to accomplish this? Also, what IS the purpose of the Mission Area if it doesn't prevent the player from going outside of the bounds?
About the author
#2
12/16/2004 (7:24 pm)
Thanks, I didn't think of searching the resources but I did search the forums for "mission area" and "mission bounds" and got no hits. Learned something new!
#3
www.garagegames.com/mg/forums/result.forum.php?qtm=mission%20area
And to make searching work much better, faster, and more reliable....
www.garagegames.com/mg/forums/result.thread.php?qt=16093
12/16/2004 (7:37 pm)
Try thiswww.garagegames.com/mg/forums/result.forum.php?qtm=mission%20area
And to make searching work much better, faster, and more reliable....
www.garagegames.com/mg/forums/result.thread.php?qt=16093
#4
12/17/2004 (8:55 am)
Reliable, yes.... nothing is worse than unpredictable results that this search function from GG ;-)
#5
12/19/2004 (5:20 am)
Thanks Gonzo!
#6
Steve
12/22/2004 (7:15 am)
Isnt there a way of getting the players current position, and then if his position is greater or less than the missions area x,y coords then he is stopped moving outside.Steve
#8
In db pro previously i would have done as so:
If keystate(w)=1 and terrain x pos(camera) >-1000 or x pos < 2000 then move player camera
Not exacyly hard db code, but the pseudo of how i would do it
Could this not be the same with tge?
Thanks
Steve
12/22/2004 (9:55 am)
Gonzo can u be more specific please - on how to use this.. i understand what the if is, but not the vars inside, x1.x2In db pro previously i would have done as so:
If keystate(w)=1 and terrain x pos(camera) >-1000 or x pos < 2000 then move player camera
Not exacyly hard db code, but the pseudo of how i would do it
Could this not be the same with tge?
Thanks
Steve
#9
%x1 = getWord(%player.getPosition(), 0);
%y1 = getWord(%player.getPosition(), 1);
which would return(in the first example)
%x1 = 500;
%y1 = 500;
To get your noundries...
%x2 = getWord(MissionArea.area, 2);
%y2 = getWord(MissionArea.area, 3);
Which will get you
%x2 = 1000;
%y2 = 1000;
Now, if you run these calculations and any of them come up TRUE on both sides of the equation, then you have a player that is out of bounds....
if(%x2 > 0 && %x1 > %x2) { %player is out of bounds }
if(%y2 > 0 && %y1 > %y2) { %player is out of bounds }
if(%x1 < 0 && %x1 < -%x2) { %player is out of bounds }
if(%y1 < 0 && %y1 < -%y2) { %player is out of bounds }
Now lets replace the values to see if the player is out of bounds....
if(1000 > 0 && 500 > 1000) { %player is out of bounds } - result: Not OOB
if(1000 > 0 && 500 > 1000) { %player is out of bounds } - result: Not OOB
if(500 < 0 && 500 < -1000) { %player is out of bounds } - result: Not OOB
if(500 < 0 && 500 < -1000) { %player is out of bounds } - result: Not OOB
As you can see, all four comparisons failed to equal true on both sides so the player is NOT out of bounds. Now, lets alter the players position to say "-1100 500 192" and run the same comparisons....
if(1000 > 0 && -1100 > 1000) { %player is out of bounds } - result: Not OOB
if(1000 > 0 && 500 > 1000) { %player is out of bounds } - result: Not OOB
if(-1100 < 0 && -1100 < -1000) { %player is out of bounds } - result: PLAYER IS OOB
if(500 < 0 && 500 < -1000) { %player is out of bounds } - result: Not OOB
In the third comparison -1100 is obviously less than Zero, and since -1100 is also less than -1000 then we have a "True" situation on both sides of the equation and therefore the player must be out of the boundry area. Hope that helps you understand it better.
12/28/2004 (6:46 am)
Tell you what, forget about the subtraction and lets just do a simple "compare values" instead... Ok, lets say your mission area is area = "0 0 1000 1000", this indicates that coordinate "0 by 0" is your centerpoint, and you have a 1000 unit radius to work with from there. So you can have coordinates that range from "1000 1000" to "-1000 -1000" to "1000 -1000" and "-1000 1000" as your boundry corners. Your Z coordinate is not needed here because you only need to know your X and Y positions. So if you use %player.getPosition() to retrieve the players position on the map, you should get a figure that could be something like "500 500 192" with your X and Y both being 500 and your Z being 192. Or you could get "-500 -500 192" instead. You can easily see in these cases that both the positions are within the Mission Area boundries because 500 is less than a 1000 and -500 is less than -1000. So how do you do the math? Like this....%x1 = getWord(%player.getPosition(), 0);
%y1 = getWord(%player.getPosition(), 1);
which would return(in the first example)
%x1 = 500;
%y1 = 500;
To get your noundries...
%x2 = getWord(MissionArea.area, 2);
%y2 = getWord(MissionArea.area, 3);
Which will get you
%x2 = 1000;
%y2 = 1000;
Now, if you run these calculations and any of them come up TRUE on both sides of the equation, then you have a player that is out of bounds....
if(%x2 > 0 && %x1 > %x2) { %player is out of bounds }
if(%y2 > 0 && %y1 > %y2) { %player is out of bounds }
if(%x1 < 0 && %x1 < -%x2) { %player is out of bounds }
if(%y1 < 0 && %y1 < -%y2) { %player is out of bounds }
Now lets replace the values to see if the player is out of bounds....
if(1000 > 0 && 500 > 1000) { %player is out of bounds } - result: Not OOB
if(1000 > 0 && 500 > 1000) { %player is out of bounds } - result: Not OOB
if(500 < 0 && 500 < -1000) { %player is out of bounds } - result: Not OOB
if(500 < 0 && 500 < -1000) { %player is out of bounds } - result: Not OOB
As you can see, all four comparisons failed to equal true on both sides so the player is NOT out of bounds. Now, lets alter the players position to say "-1100 500 192" and run the same comparisons....
if(1000 > 0 && -1100 > 1000) { %player is out of bounds } - result: Not OOB
if(1000 > 0 && 500 > 1000) { %player is out of bounds } - result: Not OOB
if(-1100 < 0 && -1100 < -1000) { %player is out of bounds } - result: PLAYER IS OOB
if(500 < 0 && 500 < -1000) { %player is out of bounds } - result: Not OOB
In the third comparison -1100 is obviously less than Zero, and since -1100 is also less than -1000 then we have a "True" situation on both sides of the equation and therefore the player must be out of the boundry area. Hope that helps you understand it better.
#10
It seems lots of my posts on diff forumns are getting answered now!
Steve
12/28/2004 (6:50 am)
Thankyou Gonzo - its nice getting some help.....It seems lots of my posts on diff forumns are getting answered now!
Steve
#11
I added this simple code (thanks to Leslie "Xyber" Young), to prevent the player from exiting, with a cool bouncing effect :
For more advanced features, look at Mission Area Forcefield V2.
12/29/2004 (11:00 pm)
A simple way to restrict the MissionArea exit is to deal with the event Armor::onLeaveMissionArea in player.cs.I added this simple code (thanks to Leslie "Xyber" Young), to prevent the player from exiting, with a cool bouncing effect :
%force = 10; %min_x = getWord(MissionArea.area, 0); %min_y = getWord(MissionArea.area, 1); %max_x = %min_x + getWord(MissionArea.area, 2); %max_y = %min_y + getWord(MissionArea.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);And I added easily a rectangular shape to mark the area...
For more advanced features, look at Mission Area Forcefield V2.
#12
TIA,
Neurosys
12/25/2007 (6:17 pm)
No one ever answered and btw this is a result of my own search for mission area.. but... What the hell does the mission area do and why do we need it?TIA,
Neurosys
#13
http://www.garagegames.com/mg/forums/result.thread.php?qt=13904
Thanks! Ignore it I shall!
12/25/2007 (6:19 pm)
And nevermind... I found the answer now in this posthttp://www.garagegames.com/mg/forums/result.thread.php?qt=13904
Thanks! Ignore it I shall!
#14
http://www.garagegames.com/mg/forums/result.thread.php?qt=13904
Thanks! Ignore it I shall!
12/25/2007 (6:41 pm)
And nevermind... I found the answer now in this posthttp://www.garagegames.com/mg/forums/result.thread.php?qt=13904
Thanks! Ignore it I shall!
Torque Owner Josh Moore