Unity Character controller bouncing - c#

I have a game object with a Character controller. I set it up to move and jump. Everything works fine, but when I add an Animator, the object bounces once after landing on some other object that contains the box collider.
I have already tried many ways, but they did not lead to a positive result. I tried to edit the fbx model, change the anchor point, change the position of the Character controller on the object.
When I removed the animator, the problem disappeared, but I need to use movement animation. And for some reason it affects gravity. Without it, the player's game object jumps higher. I've been working in Unity not so long ago and I don't remember how to solve this problem.

If you are using the RigidBody component, you may need to make a physics material for your player. The physics material defines some properties of the object such as how much it bounces. In the Assets folder: click create > physic material
This will create a physics material. Edit the bounciness and add it to the RigidBody of your character.

Related

How to detect collisions for a rotating child object in Unity3D C#?

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.

capsule collider not jumping in unity

i imported a the Unity chan character from unity assets store , when i and i added to it rigidbody and capsuleCollider ,and then i assigned to it the
JUMP00 animation as in the images , so when i hit play the character jumps but the collider is not moving up , when i add motion to move x and z axis the collider moves with the character.
This behavior is by design. Animation only move the mesh, it does nothing to collider.
One workaround to this problem is that you can attach your collider to the bone not the mesh.
I just solved my problem which has the same behavior. The cause of my problem was because I did not move the GameObject (up), I just was playing the animation, not make a really jumping for the object.
I know this old post, but I answered for the newer game programmer like me :)

How to add physics to an object in Unity 5

I'm having a problem with Physics! I have imported an object which a bridge from 3ds max to unity 5 ,but the problem is that whenever I want to walk through on it ,I just fall down. It's like there's nothing called BRIDGE! I know there must be a problem about Physics. But how to fix it ?!
When importing a model into Unity it does not have any Collider.
Even though using auto-generated "MeshColliders" is an option
I highly recommend not to use them.
You never need such highly detailed colliders in a game.
Instead, you have to
Add the colliders manually
Here is a little step by step guide
This is the imported model (made with blender) without any collider whatsoever
First thing to do is add a new box collider to the components
as shown in this gif
The next thing to do is scaling the box collider
by either entering the values manually or using the drag/GUI version like I do in the gif below
(you probably know that already but the mode can be changed to orthographic by licking the small cube in between the cones in the upper right)
If necessary you can add as many "detail" collider as you want
by repeating the steps. Sometimes sphere or capsule colliders might fit better but keep in mind that they have a higher resolution!
In this case i added another box collider representing the upper part of the car:
Thats all you need to make things collide with your object
Right now you only have a MeshFilter, MeshRenderer, and Animator component attached. You walk through it because the mesh is only being rendered. In order to add collision, add a MeshCollider component to it.
Joe offers another way to do it with box colliders. There is a bit to know about both methods:
Box colliders will take more time to set up (rather than just adding a
component) and will have less precision. They will have faster performance.
Mesh colliders do not collide well with other mesh colliders.
However, this is often not an issue. If a mesh collider has the
"convex" checkbox checked then it will collide just fine with other
mesh colliders. Small items and any convex-shaped meshes should have
"convex" checked.
For something like your bridge.. it depends on your game. If you are doing a top-down game with limited mobility (no jumping) then box colliders may work for you. If you are making a first-person game then I would strongly suggest mesh colliders. If you decide to use box colliders then you must set them up carefully. Otherwise, physics may not match up with what the player sees!
Do not worry about performance at this time. Worry about it later IF it becomes an issue. With the physics upgrade in Unity 5, it probably won't be.

Unity3D Object 'Shoving' Mechanic

I'm trying to make a 2D top-down perspective game in which I want to try and implement a shoving mechanic as a way of the player interacting with the environment or even enemies, but I can't seem to nail down the physics behind it.
(Player object (P) and interactive object (O))
My Question is: what is necessary to make this work properly? I've tried a few things out, such as having the information to add the force to the Rigidbody2D on P first and then on O and I'm trying to get it so that the player pushes the object in the direction it's facing, which I have a script for transform.up to face the mouse. I did also try to implement a dash mechanic to see if it would push an object further, however the physics meant that P would dash in a random direction as opposed to being towards the mouse
give the player object a rigidbody and a colider and the object a colider, should work no problem then!
http://docs.unity3d.com/Manual/class-Rigidbody2D.html
http://docs.unity3d.com/Manual/class-BoxCollider2D.html
should just work automatically then, Unity doing all the physics work for you
edit
if you want the object to be more strongly affected just reduce it's mass int he rigidbody in the inspector, or increase the players mass

Somethings wrong with my colliders (Unity Game Engine)

I have a character, that has a character controller attached to it I am using transform.position, transform.forward and transform.rotate to move with the 'wasd' keys, that all works fine.
However it will not collide with any sort of colliders, whether is be box colliders or mesh colliders. trigger works on my character, i.e. it can trigger an object to destroy if it passes through, but the colliders that are not set to triggers (like walls), don't block the player, the player just goes through them.
Any ideas?
Note: using C#, unity free version 4.5.1
You Should not use transform for colliding.
Add ridged body and get reference to ridgedbody.
Then use reference.addForce
Guys i figured out the problem, as the previous answer said i should not use transform with character controller, however there's no need to change any colliders, i still kept my character controller on my player, but rather i used controller.SimpleMove to move the character, that fixes the problem and i get to keep the character controller on my object (no need to add extra colliders or rigidbody to the player).
http://docs.unity3d.com/ScriptReference/CharacterController.SimpleMove.html

Categories