box colliders next to each other bug - unity3d

I work on a game in which you can build your own level and play it. You can create a cube, with a box collider, and move it where you wants. You can also change its color. But when you put two cube next to the other, the character will detect a collision on Z axis. As my character collider is a capsule, it make my character jump. If I put a box collider instead of capsule, my character is stopped.
Here is a explanatory video: https://youtu.be/xuqs1zcdDlk
I tried to overlap both colliders, but problem is still here. Colliders have exactly the same height. How should I solve this??

Go to Edit > Project Settings > Physics, and try your game changing the Default Contact Offset value untill 0.
Good luck for your game, can't wait to play it !

Related

Setting up a sliding character in the right way

I would like to try and make a game similar to Altos Adventure. I am having trouble starting.
How to set up the terrain so that my character doesnt get stuck?
I simply drew a test sprite for the ground in photoshop. What collider2d should I use?
I use polygon collider and reduce friction in the material. But the character gets stuck, hits small invisible bumbs and it feels awful. The worst part is connecting 2 ground sprites together! The point where they connect is always messy.
I have a question for the future as well. How would I add the endless part of the game?
Would having many "pieces" set up and just spawning them as the player rides down work?
I havent written any code yet as the problem is simply in the physics in my opinion.
Thanks to anyone who takes the time and tries to help!
To move your player use rigid body.AddForce(Vector3 direction, ForceMode forceMode); then create a Physics Material with friction = 0 and put it in your player's collider.

Why is my character flying off in unity 2d?

When i Click on the play button my Spire flies off into the ceiling of my map.
I have a simple png as a sprite in unity.
I use a tilemap for the level i made which has a TilemapCollider2D and a BoxCollider2D.
https://imgur.com/2tggchP <- photo of what is happening.
My character has a BoxCollider2D and a Rigidbody2D.
I'm making a side scroller in case that is necessary to know.
The gravity and stuff for the character is normal and so is the mass.
My character(s) should just stay on the ground.
I'm not exactly sure if the grey part of the backroud is the object that has a BoxCollider2D but if it does that that's your issue.
You can't have two BoxColliders overlapping each other otherwise you'll get what your seeing now, one shooting up.
I would suggest removing the BoxCollider2D on the tilemap (if that's possible) and maybe just having a BoxCollider2D on that floor in the picture.
If my answer didn't help or wasn't good enough I would be happy to help you further, just reply to this. :)

Climb down ladder in 2D platformer game

For my game, the player character requires to climb up and down ladders those are placed in the gameplay area.
At present, I can able to climb up for my player character to climb down at present I don't have anyway. Because platform box collider applied with platform effector, so for the climb up, effector does not create any problem but now after reaching the top, it becomes solid platform so now I can't able to move downside.
For climbing up, I have followed this tutorial: How To Make 2D Ladders In Unity - Easy Tutorial
I am looking to implement some physics so I can reach downside to the ladder after reaching top.
You need 2 boolean variables isClimbingUp and isClimbingDown which depend on pressed key and a second ray, which will check -Vector2.up direction. Then just add one more 'else if' statement for down direction.
Yes, I have managed to solve this, and the game is published in the stores.
You can check using the below link:
Humpty Trumpty's Border Wall
This is my overall physics setup for the stair:
I have applied a trigger collider to my stair object and disable player gravity scale when the player within the stair.
Then after within the trigger enter and exist, I have done this:
Physics2D.IgnoreCollision(m_CapsuleCollider, myStair.platformCollider, false);
Disable collision between player and platform colliders when the player is within the stair.
I don't think, Platform Effect 2D becomes useful to me in this process but I didn't remove this to remain in the safer side.
So you have to keep a reference of the platform object which is attached to Stair.
I hope you will get a general idea to solve this problem.

Capsule Collider not visible in the scene view?

I am trying to hit a ball using a golf club. My golf club has three components (three game objects: handle, shaft and head as shown in the first attached image). Head gameobject's inspector can be seen in the another attached image.
To hit the golf ball, we need a collider. So I put a Capsule Collider at head game object. But I don't see any collider at head gameobject.
The head is shown in the last image.
Why I can't put Capsule Collider at the object?
EDIT:
Thanks for the reply.
I increased the radius but still the same.
I placed a Quad in the scene and put Mesh collider onto it (called AW52Collider). Please see in the
first image. We can see the collider clearly.
But I did the same thing to Club head, as it is also a game object I should be able to put a Mesh collider. But I don't see anything. Why?
Please see in the second image.
One more thing I don't understand is when I put AW52Collider inside Club Head object, I don't see AW52Collider also. Why? Please see in the third image.
Increase the size of your collider, those values do not look like you should see the gizmos at all. Best would be to reset the collider to its default values and then play with them until you are happy.
It is best practice to create a child object with colliders on it. The reason is the placement of the collider. The collider is always centered around the pivot point of a GameObject. But you probably want to move your collider freely or disable a group of colliders manually for testing (or optimization) purposes. Also consider that an object with multiple small colliders as child objects is considered one big collider (rigidbody wise). Source (Compound Colliders)
Just enable Gizmos button and you'll find your capsule collider.
See this picture to know exactly where to find it:
(It's in the toolbar below the Scene tab)

Adding Google Street View Images to Unity Project

I'm completely new to Unity and I'm starting to work on a little game for my class. The scenario says that the main character should be placed in my home town.
Since I'm not capable of modeling my town, I tried making skybox from google street view images using free plugin I found. It looks ok, so I tried adding an avatar, and that's where I'm having troubles.
When adding an avatar, he falls trough the floor, I suppose because its only image underneath him. Then I tried adding box below his feet, and now he levitates in squat position abowe it.
Has anyone any suggestions or ideas on how to fix this? Or maybe some suggestions on different vay of doing this would also be apprechiated.
Here is a photo of what it looks like now:
https://postimg.org/image/ehklr8sg5/
The reason your character falls is because there is no "floor" yet. The skybox is nothing but a special cube that wraps infinitely around your scene. With the street view images it may appear like the character is standing on solid ground based on the optical illusion of the skybox, but they're actually floating in space. When you press play, the physics engine starts, gravity takes hold, and your character falls.
There are a number of ways to prevent them from falling.
Disable Gravity on Character
This is only a good idea if you're not planning to use physics in your game.
Select your character's root node in the Hierarchy
In the inspector, find the RigidBody component
Uncheck Use Gravity
Add Floors
Add something with a collider on it that doesn't have a RigidBody. The collider will prevent the character from passing through it and the lack of RigidBody will ensure it doesn't also get affected by physics or gravity.
Create > Plane
Set its transform position to 0, 0, 0 so it's centered in the world
Scale it up big enough for your character to land on
Uncheck the Mesh Renderer in the inspector to make the plane invisible