- Home /
Mesh Collider to a character and the maze?
Hi!
I m trying to make a maze game and my main character is a sphere.
I created my maze model on SketchUp and import it to unity. All fine till now.
The image below shows the red sphere in the maze, the maze has a mesh collider. The next image shows the maze with convex (one of the two objects must have a convex so that a collusion must happen between them two):
I imported my sphere made up from SketchUp too ( i know i can do it on unity too). I made the maze has Mesh Collider and the sphere a Sphere Collider but they don't seem to be solid at all. My sphere character goes through the walls... (i enabled Is Triger too them both with no results).
How am i suppose to make this work and have my sphere and my maze as solid meshes?
Thank you in advance
Answer by ankush_Kushwaha · Jan 15, 2014 at 11:14 AM
Your IsTrigger
must be disabled on both of the object (player and maze), both object must have colliders and one of them should be rigid body. :-)
when i untick the IsTrigger from the Sphere is looks fine but when i do the same for the maze the sphere falls half in the ground of the maze and looks weird.
Fixed: i ticked on Convex that's why i had that issue with the sphere. But the main problem remains to be the same. the objects are not acting like solid. :(
Answer by DaveA · Jan 14, 2014 at 07:32 PM
At least one of those needs a RigidBody on it
I set Rigidbody on the sphere but not working :( am i doing something wrong?
i tried another thing too:
On the start i have a secret cube to control my player for not going over the start edge (see the 1st image, the white cube behind the red sphere). The cube is a child to the maze with the name "Start_collision". The imported game object Player_Sphere has 2 children: the Player Camera & the sphere object. That sphere object child has the Rigidbody and the sphere collider ( Not Is Trigger). Now the Player_Sphere has a js script attached:
function OnCollisionEnter (theCollision: Collision) { if(theCollision.gameObject.name == "Start_collision") Debug.Log("hit the start edge"); }
Unfortunately, it doesn't print any msg on the screen! :(
Answer by Nick4 · Jan 15, 2014 at 12:30 PM
Since your maze has more than 256 polygons, it can't get a proper mesh collider. You need to create empty game objects and parent them to your maze. Then you can use box colliders on each empty game objects which are binded to your maze. But don't use any of the colliders as isTrigger. isTrigger is only used to detect collisions. Good luck.