Jump to content

[INCOMPLETE] Objects with Collision Type 'Trigger' always Box?


Recommended Posts

EDITED WITH ADDITIONAL INFO

 

Hi,

 

I'm experiencing odd behaviour - I have a simple mesh object I created to conform to the shape of a river in my level, with an invisible material set. What I want to happen, is when my player initially collides with this object, the 'in water' state is set, and when the player stops colliding with the object, he is 'out of the water'

 

As I recall, this seemed to be working fine some time ago, but (possibly in a recent beta update) I now notice that the boundaries I expect to trigger the collision are incorrect, however this behaviour seems inconsistent depending on the collision type set for the object.

 

If I set the object as 'Scene' Collision Type, and set it just above the river bed so the player can walk over it (player could obviously not walk 'through' it with this Collision Type) , and set Shape to 'Polymesh', everything works as I expect. As soon as my character 'steps onto' the object, he enters swim mode, and when i swim off the object, he resumes walking.

 

If I switch the Collision Type of the object to 'Trigger', then the enter/exit water behaviour is triggered significantly outside the boundaries of the object - Initially I thought it was using the 'Box' AABB type shape, but now it looks more like there is some transform on the shape when set to Trigger.. the collision shape appears significantly offset. Is it possible that when 'Trigger' is used, some object transforms are not being applied in the engine.

 

here are some screenshots. The first is the project, showing the shape of the 'river' object, and the second has white spheres where collision with the object named 'waterbox' occurred.. it is offset from the polymesh shape, and appears so have straight edges.. this was the only way i could think of to visualise exactly where the collisions were occuring in-game..

 

trigger_polymesh_wierdness2.jpg

 

trigger_polymesh_wierdness.jpg

 

I would expect 'Polymesh' physics shapes to work with 'Trigger' collision type, the same as the other collision types.

 

Significantly, the 'Show physics' in the editor window always shows the boundaries I expect (the polymesh) for both Collision Types, it is just not matching what is happening when the game is run.

Link to comment
Share on other sites

Hi,

 

Doesn't really work at all as 'Character' Collision Type does not trigger a collision event with 'Debris' Collision Type objects. It is possible I could define my own collision type if I had the C++ version of the engine, but I only have the Lua-based Indie version.

 

Trigger seems to be the only possibility for Character physics interaction that does not prevent movement of the character through the object.

Link to comment
Share on other sites

It is possible I could define my own collision type if I had the C++ version of the engine, but I only have the Lua-based Indie version.

 

List of inherent types:

Collision.Prop = 1

Collision.Scene = 2

Collision.Character = 3

Collision.Trigger = 4

Collision.Debris = 5

Collision.Projectile = 6

Collision.LineOfSight = 7

 

List of possible responses:

Collision.None = 0

Collision.Collide = 1

Collision.Trigger = 4

 

With the following warning from Josh concerning using the constants and not the numerical values: "You really should stick to using the named constants. Technically, the values of these are allowed to change at any time, without breaking the spec."

 

Example of use in LUA:

Collision:SetResponse(type, type, response)

entity:SetCollisionType(type)

Collision:SetResponse(10, Collision.Character, Collision.Trigger)

self.entity:SetCollisionType(10)

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Hi,

 

Thanks, that is good to know, but it is unclear if that will solve the issue anyway

 

The real problem is the apparently incorrect polymesh collisions I am seeing - I dont want to implement workarounds with custom collision types if this is indeed just a bug that will get fixed soon, plus, even if i do create a new collision type it would still need a 'Collision.Trigger' response.

 

All the built-in types that have a 'Collision.Collide' response calculate correct intersection, but block movement through the colliding object which is not what I need.

Link to comment
Share on other sites

Thanks, that is good to know, but it is unclear if that will solve the issue anyway

Yes, my response was just for the question of whether you could create custom physics types/responses via lua. As for the issue you are seeing, have you tried camera:SetDebugPhysicsMode(true) in the running game to see if the physic shapes are where they are supposed to be? Also, a map example that shows this issue would probably be beneficial. If this is an actual bug, then it helps if others can easily reproduce the problem.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Hi,

 

I'm unclear on how to provide a map example, as i don't know how to isolate just the used parts of the project easily - however I added in-camera Physics visualisation which shows correct bounds for the object, just collision events do not fire as expected when passing through the object boundary, when collision type is 'Trigger'.

 

I was able to reproduce it using the following steps:

 

Use the current Steam Beta version of Leadwerks.

 

Load the Default Terrain example

 

Add this model to the map, and rename it to 'testbox', and set its scale to something large relative to the player e.g. 10.0,10.0,10.0

:

 

http://marchingcubes.com/collision.mdl

 

 

Set Physics to 'Polymesh/Scene'

 

Add this code to FPSPlayer.lua around line 150:

 

self.camera:SetDebugPhysicsMode(true)

 

Replace this code in the FPSPlayer.lua controller (creates a sphere when the player collides with 'testbox')

 

function Script:Collision(entity,position,normal,speed)

local entityName=entity:GetKeyValue("name","UNKNOWN")

System:Print("colliding with "..entityName)

if entityName=="testbox" then

local s=Model:Sphere()

s:SetPosition(self.entity:GetPosition(true),true)

end

 

end

 

Start the world, and observe physics visualisation shows blue 'physics shape' for object as expected

 

Walk into the object and observe a sphere is created upon collision, and expected log message appears

 

Set physics type on the object to 'Trigger'

 

Start the world, and observe physics visualisation shows blue 'physics shape' for object as expected

 

Walk into the object and observe no spheres created, and no debug 'Colliding with testbox' appear in log.

 

 

Add CSG box to scene, rename to 'testbox', set to Polymesh/Trigger, and observe log messages and spheres being created correctly when you walk through it.

 

 

If you can tell me how to package a minimal map/example for you which includes the models/scripts to debug I can do so - it would be good to know if others can reproduce this behaviour too.

Link to comment
Share on other sites

  • 3 weeks later...

You can export the project and upload it to Google Drive or DropBox. I will be happy to take a look at it once you have an example I can run.

 

You can see in this test map that triggers are activated when objects intersects, not just on AABB overlap:

triggertest.rar

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...