Jump to content

Does world pick ignore collisiontype?


gamecreator
 Share

Recommended Posts

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")?

Link to comment
Share on other sites

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...

  • Upvote 1

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

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.

Link to comment
Share on other sites

  • 1 year later...

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              
  • Upvote 3
Link to comment
Share on other sites

  • 4 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...