Hot answers tagged

3

No, the 2D and 3D physics worlds in Unity are treated completely separately, using different internal physics engines (2D is using Box2D, 3D uses a variant of PhysX) If you need 3D physics, then the simplest way is to handle all of your physics objects as 3D, with appropriate constraints to keep the 2D objects from rotating out of their intended viewing ...


2

You are only checking th i-th bullet with the enemy of the same index and not with every enemy there is. You should do something like this for (int i = 0; i < Bullet.Bullets.Count; i++) { for (int j = 0; j < Enemy.Enemies.Count; j++) { if (Collisions.IsColliding( (int)Bullet.Bullets[i].position.X, ...


2

As your desired image reflects that you want it in 2D, so I have modified your current script which would draw a path from your given Game Object, decided start position, mouse or finger position would be the end position. Other than that you can specify number of elements should be drawn on the path. Well, have a look and give it a try. Comments will also ...


1

I'll throw my singleton into the mix. It checks off all four of DMGregory's criteria (see his answer). This has a lot of stuff that may not make sense. It is just covering Unity specific corner cases, and persists between scenes. It is tried and tested, and the most current version can be found on my Github. Enjoy! Usage is by having your script extend this ...


1

In C# when a struct is accessed via a getter (like transform.position), the compiler won't allow you to modify a member, because it has no sense to do that, because a getter of a struct return a brand new struct that you have to reference first. If you don't your brand new struct will stay inaccessible...



Only top voted, non community-wiki answers of a minimum length are eligible