Nimzog Posted September 30, 2014 Share Posted September 30, 2014 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. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted September 30, 2014 Share Posted September 30, 2014 Setting a collisiontype isn't enough. You also need to set a collision shape. See this tutorial: http://www.leadwerks.com/werkspace/page/tutorials_legacy/_/shapes-and-physics-r10 Quote Link to comment Share on other sites More sharing options...
Nimzog Posted September 30, 2014 Author Share Posted September 30, 2014 Thanks its working properly now. EDIT: it only collide with the player. When I move it around it does not collide with anything even when I changed the collision type to something that does not collide with a character(that is not an option). 1 Quote Link to comment Share on other sites More sharing options...
Einlander Posted September 30, 2014 Share Posted September 30, 2014 Did you set it's mass? Quote Link to comment Share on other sites More sharing options...
Nimzog Posted September 30, 2014 Author Share Posted September 30, 2014 I dint want it to be affected by gravity. Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 1, 2014 Share Posted October 1, 2014 how are you updating the position of the invisible sphere? If you are using entity:SetPosition(), it may be breaking the physics. You could try using entity:PhysicsSetPosition() 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...
Nimzog Posted October 1, 2014 Author Share Posted October 1, 2014 how are you updating the position of the invisible sphere? If you are using entity:SetPosition(), it may be breaking the physics. You could try using entity:PhysicsSetPosition() When I use PhysicsSetPosition it does not follow the player anymore... But it was a good guess. Quote Link to comment Share on other sites More sharing options...
macklebee Posted October 1, 2014 Share Posted October 1, 2014 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(). 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...
Haydenmango Posted October 1, 2014 Share Posted October 1, 2014 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(). 1 Quote Check out my game Rogue Snowboarding- https://haydenmango.itch.io/roguesnowboarding Link to comment Share on other sites More sharing options...
Nimzog Posted October 1, 2014 Author Share Posted October 1, 2014 OK I created my own collision with set response, gave a mass and set gravity mode to false. It works well thank you everyone. 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.