gamecreator Posted May 11, 2016 Share Posted May 11, 2016 I have the following code. player[0].model->Hide(); if(window->KeyHit(Key:) && world->Pick(player[0].controller->GetPosition().x, 100, player[0].controller->GetPosition().z, player[0].controller->GetPosition().x, 1, player[0].controller->GetPosition().z, pickinfo, 0, true, Collision::Scene)) { // 2 is Collision::Scene aka terrain printf("%d hit at %f, %f, %f\n",pickinfo.entity->GetCollisionType(),pickinfo.position.x,pickinfo.position.y,pickinfo.position.z); } player[0].model->Show(); This works perfectly, detecting the position of the terrain with a collision type of 2. However, if I comment out hiding the model, the function will come back with the top of the model's head, about 6 feet higher, and with a collision type of 1 instead of 2. Do I understand the documentation correctly that specifying Collision::Scene (or just 2) should ignore everything except that specific collision type ("if specified, the entity collision type will be tested against this, and only colliding entities will be tested")? Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 11, 2016 Share Posted May 11, 2016 When you specify a collisiontype in any of the Pick commands, you are setting the collisiontype of the raycast itself and effectively saying to test based on this diagram: http://www.leadwerks.com/werkspace/page/api-reference/_/command-reference/collision-r778 Also, since you have the parameter 'closest' set to true, it will return the first object that satisfies the collisiontype/collision response settings. If you want to be only able to pick the scene/terrain, then based on the diagram you should use Collision.LineOFSight. Edit: But yes, there does seem to be something quirky going on with setting the raycast's collisiontype to Scene. It is returning collisions with Scene and according to that diagram it should not. Its strange because it appears that other collision types/responses work as expected. Out of curiosity, what are you trying to accomplish with the pick? The pick position is essentially just returning the player position... 1 Quote 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 More sharing options...
gamecreator Posted May 11, 2016 Author Share Posted May 11, 2016 Ok, thank you. I'll try Line of Sight. The idea is to have a function like SpawnEnemiesAtPivot(pivot, enemytype, numberofenemies) which would spawn enemies on the terrain around the pivot location. The x and z would be random, near the pivot (except avoiding putting enemies on top of each other) but the y would be determined by that pick, so enemies would spawn right on the terrain instead of some arbitrary distance in the air and then fall. Yes, I could just put a bunch of spawn point pivots in an area and that's not the worst idea but that seems less elegant. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 13, 2017 Author Share Posted July 13, 2017 This came up again (a year+ later) and LineOfSight skipped the model and picked the terrain, as needed. But I wasn't able to find the chart macklebee linked to in the new documentation. Anyone have it? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 13, 2017 Share Posted July 13, 2017 I have a chart from +1 year ago. Not sure if it is still valid. This should be updated in the official docs though. Prop Scene Character Trigger Debris Projectile LineOfSight Prop Collide Collide Collide Trigger Collide Collide None Scene Collide Collide Collide None None Collide Collide Character Collide Collide Collide Trigger None Collide None Trigger Trigger None Trigger None None None None Debris Collide None None None None None None Projectile Collide Collide Collide None None None None LineOfSight None Collide None None None None None Responses Collision.None = 0 Collision.Collide = 1 Collision.Trigger = 4 3 Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 13, 2017 Author Share Posted July 13, 2017 Thank you Jorn! Quote Link to comment Share on other sites More sharing options...
Marcousik Posted December 12, 2017 Share Posted December 12, 2017 I think Debris collides with scene too. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted December 13, 2017 Share Posted December 13, 2017 Debris and scene are both static physics. So when a static scene object is intersecting a static debris object, is the collision function triggered? Quote Link to comment Share on other sites More sharing options...
Marcousik Posted December 13, 2017 Share Posted December 13, 2017 I'm not sure but I detected a collision between scene static and debris object with Mass. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.