New answers tagged

0

While this is not fixing your nullpointers, it will have the same result in the end. You are trying to solve a collision exception manually. Good for you that Unity ships this with a simple collision matrix. If you are using 2D physics, you need to use the 2D version. https://docs.unity3d.com/Manual/LayerBasedCollision.html


0

It appears like your "playerBird" game object has no component of type Collider2D. Make sure that one of the 2D colliders is attached. When you want to find it via GetComponent, then it must be attached to the object directly. When the collider is attached to a sub-object of the "playerBird", use GetComponentInChildren instead. Also keep ...


2

I had the same problem and I found a solution in the paper "Improving the Numerical Robustness of Sphere Swept Collision Detection" by Jeff Linahan, found here: https://arxiv.org/ftp/arxiv/papers/1211/1211.0059.pdf In short, your collision response loop should have exactly three iterations: If you collide in the first iteration you do the sliding ...


1

In Unity, you usually don't need to check if the movement destination is free, because collision detection and resolution can be handled by the engine. When you use rigidbody movement, then the engine will do so automatically and just not move the rigidbody when there is an obstacle in the way. Or if that object has a dynamic rigidbody, it will push it out ...


0

I have managed to find an answer, though I am still open to any better answers. By adding a child object to the player, I was able to position it (by initially adding a square sprite renderer with white colour, so I could see it). I positioned this child object in the area I wanted to collide. I changed my collision detection to be based on the position of ...


0

First, a design question: Why. Why do you need physics? You could simply ask if the TileMap contains a certain tile that is not walkable, for example, and then, when you walk, check your character to see if he walks into that tile. The colliders seem overkill imho. Or the other way around: why do you have the tilemap? If these were just prefabs with sprites, ...


0

You say that: Upon starting the game this is printed out, without the player having shot: Entered: Player Entered: Level Freed This suggest that you have a an instance of the Area2D in the scene tree before hand. What you want is to have the bullet and whatever it needs as a separate scene that you instance. Which is what I expect the line Bullet.instance()...


0

I implemented this and it works.


Top 50 recent answers are included