Map Boundaries...
by Derrick Austin · in Technical Issues · 11/10/2007 (11:48 am) · 10 replies
I am using this code to "warp" across the map in a circle kinda effect, how could I modify this to instead have the player hit a invisible wall kinda deal?
function GameConnection::onLeaveMissionArea(%this)
{
%longitude = getword(MissionArea.Area, 0);
%latitude = getword(MissionArea.Area, 1);
%width = getword(MissionArea.Area, 2);
%height = getword(MissionArea.Area, 3);
%tf = %this.player.getTransform();
%x = getword(%tf,0);
%y = getword(%tf,1);
%rotation = getwords(%tf,3,6);
if(%x < %longitude){
%x += %width;
}else if(%x > (%longitude+%width)){
%x -= %width;
}
if(%x < %latitude){
%y += %height;
}else if(%x > (%latitude+%height)){
%y -= %height;
}
%found = ContainerRayCast(%x SPC "1000", %x SPC %y SPC "-1000", $TypeMasks::TerrainObjectType, %this.player);
%newPosition = getwords(%found,1,3);
%this.player.setTransform(%newPosition SPC %rotation);
}About the author
#2
11/11/2007 (3:01 pm)
No, instead of repeating just like an invisible wall at the edges...
#3
You got 3d Game Programming All In One, didn't you? Awsome book.
11/13/2007 (2:05 pm)
You could create an invisable .dts file, and change it's scale untill it fits the edge of the map. Just make sure it has a collision mesh on it.You got 3d Game Programming All In One, didn't you? Awsome book.
#4
Yup, great book. The above code is actually from "Advanced 3d Game Programming All In One" though ;) lol, its just about the same just a little more in depth on stuff missed in the first book. Check it out if you haven't!
Just starting to get this game engine figured out, having fun though. I lack a lot in the graphics/design/creativity side of things, but I consider myself a pretty good programmer so we'll see how it turns out. If nothing else, I'm getting some valuable experience! lol
11/13/2007 (3:31 pm)
Thanks Nathan, I was thinking of something like that but I didn't think of the scale deal and I REALLY didnt want to walk all around the map putting down "fences" lol.Yup, great book. The above code is actually from "Advanced 3d Game Programming All In One" though ;) lol, its just about the same just a little more in depth on stuff missed in the first book. Check it out if you haven't!
Just starting to get this game engine figured out, having fun though. I lack a lot in the graphics/design/creativity side of things, but I consider myself a pretty good programmer so we'll see how it turns out. If nothing else, I'm getting some valuable experience! lol
#5
I made a box with no texture file and with a collision mesh.
I load inside the box, and I don't see the box (Which is good.)
I can leave the box and then I can see the box (Bad)
I can't get back inside the box (Good that collision works on one side, but I shouldn't be able to leave in the first place...)
Any ideas?
11/13/2007 (4:09 pm)
Ok, here is the current problem. I made a box with no texture file and with a collision mesh.
I load inside the box, and I don't see the box (Which is good.)
I can leave the box and then I can see the box (Bad)
I can't get back inside the box (Good that collision works on one side, but I shouldn't be able to leave in the first place...)
Any ideas?
#6
I can get the walls to work by building the box a different way. Instead of a box then cutting off the top & bottom I made four sides and that works, but I still have a blue texture on it... If I could make it invisible I'd be a happy camper! :)
11/13/2007 (4:14 pm)
BTW, that is milkshape 3d.I can get the walls to work by building the box a different way. Instead of a box then cutting off the top & bottom I made four sides and that works, but I still have a blue texture on it... If I could make it invisible I'd be a happy camper! :)
#7
I used a transparent png as the texture and in milkshape the box is invisible. In the game, however, the box is now gray on 3 sides and white on the other.
11/13/2007 (4:55 pm)
Ok, update:I used a transparent png as the texture and in milkshape the box is invisible. In the game, however, the box is now gray on 3 sides and white on the other.
#8
1. You must make a box out of planes, basically an inside out box, or else you can escape.
2. I used a transparent png as the texture for the box.
3. When exporting from milkshape, click on the material name, then the edit button. This brings up a new screen. Underneath "Flags" check the translucent box.
Thanks for your help everyone!
11/13/2007 (5:21 pm)
WOHOOO!!! Ok, for future readers:1. You must make a box out of planes, basically an inside out box, or else you can escape.
2. I used a transparent png as the texture for the box.
3. When exporting from milkshape, click on the material name, then the edit button. This brings up a new screen. Underneath "Flags" check the translucent box.
Thanks for your help everyone!
#9
11/14/2007 (4:21 am)
Also, you can choose to export the object as a collision mesh. It won't be visible.
#10
In order to make the box where you can't walk right through it you have to regroup the box, then rename the group: collision-1.
It is still visible if that's all you do though.
11/14/2007 (7:08 am)
Oh, actually I forgot that step ^^In order to make the box where you can't walk right through it you have to regroup the box, then rename the group: collision-1.
It is still visible if that's all you do though.
Torque Owner Caleb
Default Studio Name