Using a brush as invisible trigger.

Blitz3D Forums/Blitz3D Beginners Area/Using a brush as invisible trigger.

Sph!nx(Posted 2009) [#1]
Hello all!

Another n00b question from me!

I'm working on a 3D game with a world created with 3D world studio and I've build a large brush that needs to be invisible, and then when the player walks in, something happens. It's function is a simple 'area trigger' so to say.

I got it working so that it turns invisible, but after that, I hit a problem. If I do not setup collision (entitytype, const blabla=3,collisions, and in the loop If entitycollided....)

It works if all collision is enabled, but I want to let him pass thruogh the invisible brush but if I turn off the collision the action doesn't get triggered.

Is there a way to use the collision without making the player stop when he makes contact?


Thanks!


Ross C(Posted 2009) [#2]
Why not use a pivot? And check to see if the player is within a certain distance of this pivot. Then you don't need to bother with the blitz collision system.

Tbh, i'm not entirely sure what your explaining up there, so i'm suggesting an alternate method :)


Sph!nx(Posted 2009) [#3]
I understand, but I'd like to a brush for it. It has to be possible.

I would like to make the brush invisible and has no real collision for the player. The idea is than, that when the player walks through the invisible 'ghost' brush some other things get triggered.

The brush is a child of the map's mesh. It's found through a loop.


Ross C(Posted 2009) [#4]
What do you mean by brush? I'm unsure of what you are refering to, as in blitz a brush is a collection of properties, assigned to a surface.


Sledge(Posted 2009) [#5]
Is there a way to use the collision without making the player stop when he makes contact?
No, because a collision system prevents meshes from intersecting with one another by definition. Check out MeshesIntersect() instead, but don't use it because it's relatively slow whereas Ross' suggestion is pretty much optimal.


jfk EO-11110(Posted 2009) [#6]
Is there a way to use the collision without making the player stop when he makes contact?


This is a frequently asked question and Sledge is right, this won't work by default, but there are some tricks to achieve what you want. Meshesinstersect is pretty slow and IMHO usually not a solution.

Here's my way:

After moving the entity, but before the updateworld you will store its entityX etc in some variables. Then you can do the updateworld and after that you can check for collision, as usual. Now, after the collsion check you can Re-position the entitiy to the stored coordinates, then Resetentity it.


Zethrax(Posted 2009) [#7]
I've got some code in the code archives that will do that for you. Link below.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1901


Sph!nx(Posted 2009) [#8]
Thanks everybody!!

@ Ross,
Well, I have a half-life modding background and there we call a single placed block, a brush.

@ Bill,
Thanks m8! I will take a look right away!


Ross C(Posted 2009) [#9]
Ah, i wee bit of a confusion then, sorry :)


Sph!nx(Posted 2009) [#10]
No problem! :)

Hmm, I kinda wanted to make my water from a brush as well. Then the effect would be, when the player collides with the water he can pass through but get pushed upwards to the surface.

I kinda know how to set that up, but how would I make the water if I cannot use a brush for that?


Mortiis(Posted 2009) [#11]
You can use custom entities, I suppose you use the LoadWorld() system that Leadwerks provided for Blitz3D. Just edit the "entites.def" file in your 3d World Studio folder, and in your custom loadworld source file, add your new entity and set it so it loads a chunk of mesh and add your water preferences to it.


Sph!nx(Posted 2009) [#12]
I have that already, but it gave me a problem when using that setup for invisible triggers.

The water has the same setup, so I'm afraid I will get the same results. I will try it again.


Zethrax(Posted 2009) [#13]
For the water problem, you could use the OBB (Oriented Bounding Box) codelib I have at: http://www.blitzbasic.com/codearcs/codearcs.php?code=1920

Or you could use a simple AABB (Axially Aligned Bounding Box) test. You can probably find a few examples in the code archives.

Another option would be to use the Nuclear Glory collision system, which allows moving target entities: http://nuclearglory.com/products/ngc/

If you want proper bouyancy, then you will probably need to go the full physics engine route. There are a few different physics libs and related tools in the toolbox section of this site ( http://www.blitzbasic.com/toolbox/toolbox.php ). You could also try out the Newton wrapper at: http://www.blitzbasic.com/Community/posts.php?topic=66659 ( download from http://itmbin.nm.ru/newton/newton.zip - purchase from https://www.plimus.com/jsp/buynow.jsp?contractId=1684727 )


Sph!nx(Posted 2009) [#14]
Thanks Bill!

I happen to have the Nuclear Glory Collision System! I forgot all about that one!

So, if I understand correctly, I can use the NGC system to let brushes have a collision, without having the player stop on colliding, but still be able to use the collision to have other effects, like a trigger action, or alternate gravity effect (for water)?


Many regards,