I have been following the Unity 2D rougelike tutorials. The inspector returns no console errors when run.
The player moves on a grid and should collide with objects, some should trigger upon moving over them and others should prevent movement, the objects that activate upon trigger work as intended. The player has a Rigidbody 2D and Box Collider 2D and is set to is kinematic. The objects that do not work as intended are the walls, the outer walls should block movement entirely, the inner walls should be breakable and the enemies can not be damaged or damage the player. The walls all have a Box Collider 2D. The enemies also have a Rigidbody 2D and is set to is kinematic Game
It's normal that the walls don't block your player. You have set the isKinematic to true. What that does is
Controls whether physics affects the rigidbody.
So when you set it to true, physics no longer affect your player and he will not collide with anything.
From the Unity documentation:
If isKinematic is enabled, Forces, collisions or joints will not affect the rigidbody anymore. The rigidbody will be under full control of animation or script control by changing transform.position.
You should set the isKinematic to false if you want your player to be able to colllide with different objects.
Related
I started a 2d game and my character with a boxcollider gets stuck to walls (created with a tilemap so with a tilemap and composite collider)
I saw solutions to this where you have to put a physics material with no friction on the player, however if i do that it messes up other movements that use friction (such as a slide)
Is there a way to fix it without physics material?
You can put a physics material with low friction on walls instead of on player
or
you can write a script that when player collide with walls, push player away from wall a little bit depending on the normal of hit point.
I am making a First Person Shooter and I have a rigged player with a mouse look script, and I used to rotate the spine with spine.transform.rotation, but this method does not look for collisions, this means if I rotate and I am standing near to a GameObject, I glitch/bug through the object. So I tried to do it with a Rigidbody but this doesn't seem to work, I tried: rbSpine.AddTorque(new Vector3(mouseLook.y,0,0), ForceMode.Force);. This doesn't do anything. And I have another problem with the Rigidbody, I've only a rigidbody attached to the spine, my player has multiple simple collision and these overlap eachother a little, and my rigidbody is pushed away into the air slowly. Does anyone know a solution for this?
I put a rigidbody component on the player, this will take care of the collision detection for itself and all its child objects.
Basically I have teleport zones set up to access new areas within the level. This is only supposed to respond to the player's box collider. However, I attached a cube to the player, disabled the mesh render and use its collider to detect enemies. Unfortunately, the detect enemy collider touches the teleport zone and warps me to the new position well before my player gets near it. I tried to change the tag on the enemy detection collider but it still teleports.
How do I go about making the teleport object ignore the player's enemy detection collider?
I'm using Unity 5.3.8 and C#
Change player's GameObject layer to Player. Then, create a new layer called Teleports. Go to Edit -> Project Settings -> Physics. Then, under Layer Collision Matrix, in Teleports row uncheck everything except for column under Player.
Now, objects in Teleports layer will only collide with objects in Player player.
After updating from unity 5.5.2 to 2017.3 the Player character does not collide with objects(evironment asset) and is passing through them, all the objects have mesh collider with convex on, This is only happening in one of the level(scene) in the game while in rest of the level(scene) the player behaves normal and is colliding with objects.
Player settings
object settings
The player's rigidbody is kinematic. I would try by disabling that property.
I'm stuck on this sphere has a CircleCollider2D and rectangle has a BoxCollider2D i increase the offset of BoxCollider. But why sphere not collide from it's border. Sphere go inside and then collide just like this.
I want that it's collide when sphere touch it's border.I also check with default radius but the same situation occur.
Trigger
The scripting system can detect when collisions occur and initiate actions using the OnCollisionEnter function. However, you can also use the physics engine simply to detect when one collider enters the space of another without creating a collision. A collider configured as a Trigger (using the Is Trigger property) does not behave as a solid object and will simply allow other colliders to pass through. When a collider enters its space, a trigger will call the OnTriggerEnter function on the trigger object’s scripts.
http://docs.unity3d.com/Manual/CollidersOverview.html
You need to close isTrigger and use OnCollisionEnter(...).
For example this is my script of wood(which is below ). A smaller wood will be going down.
This is the beginning of my game
If I set isTrigger option true, onCollisionEnter2D function doesn't work. I need isTriggerEnter() method instead. it goes through my wood layer.
But if I set isTrigger false onCollisionEnter2D will be working. It will stay on my wood layer.