Game Development Community

Collision with Player, but not projectile???

by Infinitum3D · in Torque Game Engine · 09/12/2008 (11:38 am) · 16 replies

I created a bottle in StudioMax, with Collision-1 and Col-1. Exported OK. Ingame, Player (Kork) collides with it, but when I shoot it with the crossbow, it just kinda flickers and the projectile keeps going, hitting the wall two meters behind the bottle, as if the bottle wasn't there.

Any ideas?

I went back into Max and deleted the collision mesh, re-did it, and re-exported. Deleted .dso's, and restarted Torque, but same problem. I didn't have this problem with any other art.

The only difference is My old art was done in Max using centimeters, and so was very large in scale in Torque. The bottle was done in meters, so it looks fine in Torque.

What's up?

Tony

#1
09/12/2008 (12:57 pm)
Could be the class you are using for the bottle. (eg: StaticShape, Item, etc). It doesn't sound like it would be the art.
#2
09/12/2008 (12:59 pm)
If a mesh is somehow incorrect or non-convex, a collision with objects such as Rigid's and Projectiles will not register. But a player collision will, make sure the collision mesh has no problems whatsoever.
#3
09/12/2008 (2:32 pm)
Thanks for the comments. I was under the impression that the Max2Dts exporter compensated for any concavities. I think that's where my problem lies.

I'll check and post an update.

BTW - What IS the difference between the StaticShapes Class and the Item Class? Nevermind. That's a whole other thread topic :)

Tony
#4
09/13/2008 (2:49 pm)
Have you set up the LOS collision meshes? they are used for projectile collisions and I believe raycasts as well.
www.garagegames.com/docs/artist/official/3D%20Studio%20Max/Simple%20Shape.html#C...
#5
09/13/2008 (9:41 pm)
Well item collisions are handled differently. It's called at a different time (when checking for triggers) and usually shouldn't actually collide with you, but interact more in the way a trigger does. Players also have an adjustable item pickup radius so they can be within a few feet of an item to call the onCollision() (which is usually used for something like deleting the item and adding a weapon the the players inventory) while staticShape's just collide. You can still use an onCollision() to add things to your inventory and despawn the object, but it's wierd to be running into it, stopped, pick up the item, and then start running again.

Bruce is right that you should set up LOS collision meshes as well, I thought you had already included those. As far as Max2Dts compensating for concavities, I can't say if this is true as I have never used it. I can still see it being more efficient (and not too much extra effort) to manually create convex meshes. If the object is a small bottle you shouldn't need something more complex than a box for an shape or item. If it's going to be rigid, than an 8-sided cylinder should work just fine without anyone being able to see it a bit of off-balance near the neck. And the LOS meshes can be as simple as a box in either case, as it is not used for motion simulation.
#6
09/14/2008 (8:40 am)
LOS is "line of sight", right?

That would make sense for raycasts. Do I just clone my Collision-1 as LOS-9 and clone Col-1 as LOScol-9 or is there more to it?

I'm still a little unsure of the differences between ITEM and StaticShape. I thought they were interchangable. But now, I think I should use ITEM for dts that have datablocks (for interaction) and StatocShape for things that are just decorative or 'non-functional' (hence, Static)?

Is there a general rule-of-thumb like that?

Also, should ALL dts have a LOS-9, just in case its needed at some point? If so, I need to go back and redo my entire portfolio :)

Tony
#7
09/14/2008 (9:27 pm)
I think any dts that you want projectiles to hit should have LOS collision, so it's a good practice to put it in there unless you have a reason for being able to shoot through something. I'm not sure that it matters, but you might want to use LOS-1 and LOScol-1 because its the first LOS collision mesh. And the mesh could be a clone of your Col-1 but the least amount of polys that you can use and still get a satisfactory effect is what you are looking for.
#8
09/15/2008 (5:57 am)
Are you sure LOS-1 and LOScol-1 are allowed? The SimpleShape tutorial shows LOS-9 to LOS-15...

I'll try it both ways.

Update: I tried LOS-1 and LOScol-1, but it didn't affect the projectile, so I tried LOS-9 and LOScol-9, still no change to the projectile collision.

My mesh is just a simple cube around the bottle, six sides, 12 polys, no convex issues...

Am I doing something wrong with my naming conventions, like case-sensitivity or something?

My collision markers are dummy objects and my collision meshes are boxes linked like the tutorial shows...

I guess I don't NEED to have projectile collision with bottles, but I'd still like to figure this out.

Does anyone have a .3ds or .Max file with LOS set-up that they could upload for me to see?

Thanks!
Tony
#9
09/15/2008 (8:00 am)
Just to reiterate in plain speach:

A working COL mesh blocks everything, players, projectiles, raycasts.
A working Col mesh is like any other object mesh but has to be convex, sealed, triangulated and with normals facing out.

A broken COL mesh (not made like the description above, eg not convex or sealed) will not stop projectiles or raycasts but is likely to cause collision against dynamic objects like the player.

A working (convex, sealed, triangulated, normals) LOSCOL mesh stops projectiles and raycasts but not dynamic objects - the player can run through it.

At least that's what I learned playing around with them.
#10
09/15/2008 (9:54 am)
Thanks Steve.

I'm just going to start again and see if I made a simple mistake somewhere.

AHA!!!

Here's an issue... It works fine as a static shape, but when I code a datablock as
ItemData(bottle1Shape)

I lose my collision detection???

Does that mean I need to use

StaticShapeData(bottle1Shape)

???

Update: I found the collision mesh, but its Above the object??? Just immediately on top of the obj

Tony
#11
09/15/2008 (4:02 pm)
Item's don't seem to register collisions based on convexes or meshes, in the Player's findContact function it expands the Player's bounding box based on the pickup radius, and checks if the Player's and Item's world boxes overlap. If so it will queue a collision. And in the Projectile's collision detection, none of the collision masks include the ItemObjectType.

Items should not be used in place of staticShapes. Items are able to move around, and item collision effects are meant to be much different. Both objects can have onCollisionFunctions, but Item's are much more suitable to have an effect on interaction without the player actually impacting it. Think of item's as Triggers; except with a shape inside of them, deletable, respawn-able, and only registering effects onEnter.
#12
09/15/2008 (6:33 pm)
Thanks Morrock, but how can a player interact with something without actually impacting it? I understand the onEnter function, but you don't enter an item. Can you affect it just by getting within an item's radius? How do you code it?

Tony
#13
09/15/2008 (7:52 pm)
Quote:Update: I found the collision mesh, but its Above the object??? Just immediately on top of the obj
You haven't gone and resized or possibly moved something without using the box trick? If the collision mesh is not in the same place as it is max, try the box trick on the object and then recreate the collision mesh and bounding boxes.
#14
09/16/2008 (4:29 am)
I used F-12 to center the objects at 0,0,0 in Max, but I'll try the box trick and see if it changes things.

Thanks!
Tony
#15
09/17/2008 (6:37 pm)
Quote:but you don't enter an item. Can you affect it just by getting within an item's radius? How do you code it?
That's exactly what I meant, I was trying (unsuccessfully) to compare it to something else within the engine. Basically, the onCollision for an Item is called when the player get's within the item's radius distance of it. By impacting, I mean hitting and being repelled by the object, not just intersecting it's area. The player when colliding with an Item will not be forced around/over the Item. If you use the same model as a staticShape the player will hit the StaticShape and stop being forced to go around it (or step on the object if it is less than the stepHeight). You can run right through items, you cannot with StaticShapes.
#16
09/18/2008 (4:23 pm)
Thank you everyone for your help. There were several problems with my .DTS's, but I think I have them worked out.

I'll try to upload the models this weekend.

Thanks again. I learned something from all of you.

Tony