issue with character controller collider in a c# unity 3d game - unity3d

I'm having a peculiar issue with my character controller collider. in the image provided the controller SHOULD fall down the side of this cube object, yet it "floats" or "hangs" on the corner which isn't a detrimental problem, but is something I'd like to fix now rather than later, any ideas?
image of the controller statically floating on the edge of a cube object
I initially thought this issue may of been caused by incorrect properties within the controller, however after experimenting with the values the issue has not be resolved. I even tried ray casting to determine whether the controller is actively colliding with an object, but to no avail.

The problem is
it seems that the problem isn't directly on the collider but rather on the material you're using (which in this case, none)
Solution
from your project's asset, right-click and select create -> Physic material. From that physic Material, set the both Dynamic and Static friction to zero, then just draw that physic material to the game object. you can also adjust the friction depends on your needs

Character Controller has a skin width. Its an extra layer of collider which may cause this. Also check if the collider is within the capsule bounds. You can check out this article on Unity Character Controller for more details.

Related

When i add rigidbody, animation makes player float. In Unity

I am trying to play the animation but whenever i add rigidbody, player starts to float in the air at the constant value (which is 3.5 Y). No script is attachted atm.
I tried to remove rigidbody which solved the problem, but i need it so deleting rb is not an option. Gravity values are normal and the other animations are from mixamo (i didn't do the animations).
Based on the information provided here is what I'm thinking:
The root cause of this is that your character model when effected by gravity is being pushed to the ground and foot IK is causing the legs to end up looking like your screenshot above.
Some common approaches to this problem:
Create an empty object called player (Controls Rigidbody/Capsule Collider/Character Logic)
Add the 3d Model as a child of this object (Animator/Mesh/etc).
On the root object add your rigidbody as well as a capsule collider (prevents character model from colliding with the environment due to gravity).
With this setup animations can be done on the model (+foot IK) without gravity causing issues.
Okay i just solved the problem. Problem was neither rigidbody nor animation.
The collider of mesh (ground) has option checked "is Convex". I turned it off, problem solved, player is not floating anymore.

Player falls halfway throufh the floor till the outer edge of collider. instead of the inner edge

As you can see in the included video the player falls over the floortile till the outer edge of the floor. Instead it should stop at the inner edge of the tile so it looks like its standing ontop of the tile. Can anyone help? I cant find anything on the internet regarding my issue.
Im sorry if this is a easy fix. Im a beginner. This for a school project :)
Video: https://streamable.com/99jz2o
enter image description here
Photo of sprite standing on the wrong edge of the tile.
Edit: I went back to the tile palette and redrew the level. This time selecting the game object + bitmap again. Now it works. Probably the reason why it didn't work was that when I drew the level I had not added Tilemap Collider 2D and Composite Collider 2D. Now redrawing with those 2 components added it works as it should!
The problem is with your tile map collider. Instead of using this, set empty game objects as children of the objects that make up the . Then, add BoxCollider2Ds to each one, and add scale them to fit the map. If that doesn’t work, then it is either a problem with the rigidbody, or the box collider, make sure that all of the settings are set to default, then slowly change them back, and you will discover what is causing the problem. Then you can comment on this post what variable changed it.
Your issue is the Composite Collider. The docs specify that they
do not define an inherent shape. Instead, it merges the shapes of any
Box Collider 2D or Polygon Collider 2D that you set it up to use
When you attach a BoxCollider2D or PolygonCollider2D, there is a check box on them that specifies Used by Composite. When checking this box, other fields will disappear as they are now controlled by the CompositeCollider.
To use this collider, make a new object that will hold all your other colliders or make a few that hold sections of your map. Give this new parent object a CompositeCollider2D and give all the children BoxCollider2D or PolygonCollider2D. After this, make sure to check the box Used by Composite on the children Colliders.
Edit: Sorry just saw you were using a Tilemap. Just make the CompositeCollider a parent of your Tilemap while keeping the Used by Composite checked.
Edit 2: I am not too familiar with Tilemaps with Composite Colliders, but one other solution you can try before re-childing is changing the Geometry Type field on your CompositeCollider from Polygons to Outlines.

Will a raycast or collider detect an unrendered mesh in Unity3D?

I have a 3d object (a capsule) that I'm using in lieu of a character model because the project is going to be from a first person perspective. You can choose in the inspector whether to render the object's mesh or not. Since this object is meant to be invisible and only a hitbox, I want to know if raycasts and colliders will still detect it. I'm assuming yes because the object seems to behave normally with the physics, but I want to avoid complications in the future.
The only thing that matters for physics is the colliders and rigidbodies, It doesn't care about meshrenderers

SceneKit physics issue with dynamic bodies

Here is an interesting issue that i have been stuck on for a while and couldn't figure out. I'm playing around in SceneKit (using swift). Whenever or wherever i attempt to put objects with a dynamic physics body into a node hierarchy (i.e add them as a child to another node), the physics bodies separate from the models (sometimes the models just fly away etc). It always works perfectly if I set the bodies to static. Has anyone heard of such thing?
Edit:
Sorry if it was slightly unclear previously. Just to add some more information on the issue:
I create the parent node multiple times in a scene. The first time it is created everything is perfect, even objects with dynamic bodies. Now if i create another instance of the parent node further down the z axis for example, the dynamic physics bodies appear to be exactly in the right place but the 3d model not connected to the physics body. Sometimes the model is in sight but nowhere near the physics body or not to be seen at all. If it is visible, as soon as my main game object collides with the dynamic body, the physics body responds as expected but the model disappears instantly. So just to clarify, the dynamic physics body is behaving normally but my imported model that the dynamic body belongs to does not. This is only the case when my object is in a node hierarchy.
As far as setting them to not be affected by gravity, I actually do want them to be affected by it!
Thanks!
Sam
There is a difference between the location of SCNNode.presentation and the node itself. The physics engine will move the presentation. If you set properties on the SCNNode like rotation, position, etc it should reset the node and presentation to match or you could call reset* (not in front of docs right now to get the right name) to reset it manually if needed.
As Mago said, there is probably gravity moving your dynamic bodies. You can turn gravity off from the SceneView's physics engine property, or you can set the physics body's property to not be affected by gravity and see if that fixes it.
Given your description I'm not sure exactly what you observe since the physics body isn't visible just the geometry attached to the SCNNode. Perhaps a little more detail of what you observe that leads to the conclusion that "the physics bodies separate from the models"?

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