Jump to content

Model created in C++ don't collide


Nimzog
 Share

Recommended Posts

I'm trying to created a special move collision sphere for my game and when I create them in C++ with a code like this :

 

//create the collision sphere for the model
CollisionSphere = Model::Sphere();
CollisionSphere ->SetPosition(player->GetPosition());
CollisionSphere ->SetMaterial(invisiblityMat);
CollisionSphere ->SetCollisionType(Collision::Character);

 

later I add a CollisionHook and some code that will make it follow the player around. As I track the collision of this Sphere nothing happens.

 

I later tried to make a prefab with all the settings and sill the same result.

 

I decided to let the sphere there and see if it collides with the player and it didn't, but if I leave the prefab in the map it would collide with the player.

 

I am a total loss here.

Link to comment
Share on other sites

When I use PhysicsSetPosition it does not follow the player anymore... But it was a good guess.

PhysicsSetPosition() failed probably because the entity had no mass. How are you updating the position of the sphere? Either code or an example demo would be helpful. Also, another way to troubleshoot is to use camera:SetDebugPhysicsMode() to see how the physic shapes are moving and are located where you expect them.

 

And to what Einlander was suggesting - a csg primitve without mass or a script, and the engine will think the csg is a static entity and I believe try to optimize it into one mesh along with other static csg's with no script (but that might just apply to the editor and loaded maps - can't say for sure as the documentation is lacking in this area). So add a mass and since you don't want it to be affected by gravity, use entity:SetGravityMode(). Then to prevent SetPosition() from possibly breaking the physics, try using PhysicsSetPosition().

  • 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

If you just want to check if your sphere has had a collision but you don't want it to actually collide you could set the collision type to Collision.Trigger. If you want it to collide with more then just Character collision types you will have to create your own collision type using Collision:SetResponse().

  • Upvote 1
Link to comment
Share on other sites

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