Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TheBoredMan5 · Apr 29, 2014 at 12:52 AM · physicsrigidbodycharacter

My character is controlled with Rigidbody, How do I make my character NOT run through objects?

I am controlling my character with a basic Rigidbody component, a capsule Collider, a simple bot control script and an Anim Triggers script. My camera is at a 3rd person view. When I run into an object. My character just runs right through it. And when I add a Rigidbody component to the object itself. Then my character pushes the object. How do I get the object to NOT move and my character to NOT go through it?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ToxxicSin · Apr 29, 2014 at 01:17 AM 0
Share

The issue is probably your bot control script. $$anonymous$$ind if I look at it? You're more than likely using something such as transform.translate(); ins$$anonymous$$d of rigidbody.velocity or rigidbody.AddForce();

avatar image TheBoredMan5 · Apr 29, 2014 at 01:39 AM 0
Share
 using UnityEngine;
 using System.Collections;
 
 // Require these components when using this script
 [RequireComponent(typeof (Animator))]
 [RequireComponent(typeof (CapsuleCollider))]
 [RequireComponent(typeof (Rigidbody))]
 public class BotControlScript : $$anonymous$$onoBehaviour
 {
     [System.NonSerialized]                    
     public float lookWeight;                    // the amount to transition when using head look
     
     [System.NonSerialized]
     public Transform enemy;                        // a transform to Lerp the camera to during head look
     
     public float animSpeed = 1.5f;                // a public setting for overall animator animation speed
     public float lookSmoother = 3f;                // a smoothing setting for camera motion
     public bool useCurves;                        // a setting for $$anonymous$$ching purposes to show use of curves
 
     
     private Animator anim;                            // a reference to the animator on the character
     private AnimatorStateInfo currentBaseState;            // a reference to the current state of the animator, used for base layer
     private AnimatorStateInfo layer2CurrentState;    // a reference to the current state of the animator, used for layer 2
     private CapsuleCollider col;                    // a reference to the capsule collider of the character
     
 
     static int idleState = Animator.StringToHash("Base Layer.Idle");    
     static int locoState = Animator.StringToHash("Base Layer.Locomotion");            // these integers are references to our animator's states
     static int jumpState = Animator.StringToHash("Base Layer.Jump");                // and are used to check state for various actions to occur
     static int jumpDownState = Animator.StringToHash("Base Layer.JumpDown");        // within our FixedUpdate() function below
     static int fallState = Animator.StringToHash("Base Layer.Fall");
     static int rollState = Animator.StringToHash("Base Layer.Roll");
     static int waveState = Animator.StringToHash("Layer2.Wave");
     

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by JacobHockey13 · Apr 29, 2014 at 01:01 AM

I would try making the mass of your object very large in comparison to the character. Hope this helps.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Jeff-Kesselman · Apr 29, 2014 at 01:30 AM

There can be a few things wrong here:

  1. You might have your character set to isKinematic. if you do this, then the object will not be effected by forces and this includes the force that keeps you from running through objects

  2. You might not have a collider on the object you a re running through. Both objects need a collider for a collision to take place.

  3. You might be moving so quickly that you are experiencing a frame miss. This is when ou or on one side of the colliding object in one frame and the other side in the next frame. The default collision only checks at frame position so you would miss the colliion. The solution is to set your moving object's Rigid Body Collision Detction mode to Continuos or Continuos Dynamic. More information on that is here: https://docs.unity3d.com/Documentation/ScriptReference/CollisionDetectionMode.html

Note that Continuos collision will chew into your frame rate, Continuoss Dynamic will do so even worse.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TheBoredMan5 · Apr 29, 2014 at 01:53 AM 0
Share

$$anonymous$$y character is set to is$$anonymous$$inematic, Both objects have a collider. And changing the Continuos collision setting did no good.

avatar image Jeff-Kesselman · Apr 29, 2014 at 02:39 AM 0
Share

Thats your problem. If you are set to Is$$anonymous$$inematic then you will not get stopped by collisions. Being "stopped" is really having a force applied to you in the opposite direction of motion, and Is$$anonymous$$inematic prevents any forces from effecting the object so set.

avatar image TheBoredMan5 · Apr 29, 2014 at 03:01 AM 0
Share

THAN$$anonymous$$ YOU SO $$anonymous$$UCH!!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Make rigidbody walk like character controller 6 Answers

jet pack physics with character controller 1 Answer

How do I make a rigidbody move on command (ie A Player Character)? 1 Answer

Character Controller Jittering 0 Answers

How to prevent friction for character along vertical surfaces? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges