Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Dark_Shadow_12 · Sep 01, 2016 at 12:00 AM · collisioncolliderscollision detectionsupport

Why can my character go through objects with collides on them?

Hello. So, i have a character in my game that I a working on. for the most part it works perfectly fine, but Until i recently change the character movement behavior to something that works, My character can walk right through an object. For example, I have the box in my setting and when i should be colliding with it, I go straight through it!. In case you need to know, my 3d model is parented to the camera so the movement script works, and the camera has a rigid body component attached to it with continuous dynamic physics. Here is the script for my character movement:

 using UnityEngine;
 using System.Collections;
 
 public class PlayerMovement : MonoBehaviour {
 
     public float speed = 6f;
     Vector3 movement;
     Rigidbody playerrigidbody;
     bool IsFlying = false;
 
     void Start () {
 
         playerrigidbody = GetComponent<Rigidbody>();
     
     }
     
     // Update is called once per frame
     void FixedUpdate () {
       // movement
         float h = Input.GetAxisRaw("Horizontal");
         float v = Input.GetAxisRaw("Vertical");
         move(h, v);
 
         float Xrot = Input.GetAxisRaw("Mouse X");
 
         transform.Rotate(0, Xrot, 0);
 
 
         Vector3 speed = new Vector3(h, 0, v);
 
        speed = transform.rotation * speed;
 
         if (Input.GetKey(KeyCode.Space))
         {
             if (IsFlying == false)
             {
                 IsFlying = true;
                 GetComponent<Rigidbody>().velocity = new Vector3(0, 6, 0);
                 
             }
         }
 
     }
 
     void move (float h, float v)
     {
         Vector3 Speed = new Vector3(h, 0, v);
 
         Speed = transform.rotation * Speed / 7;
 
 
         movement.Set(h, 0f, v);
 
         playerrigidbody.MovePosition(transform.position + Speed);
     }
 
     void OnCollisionEnter(Collision col)
     {
         if (col.gameObject.name != "prop_powerCube")
         {
             IsFlying = false;
         }
     }
 
 }
 
 
Comment
Add comment · Show 1
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 doublemax · Sep 01, 2016 at 12:06 AM 0
Share

$$anonymous$$aybe you accidentally checked "Is Trigger" in the collider settings?

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Dark_Shadow_12 · Sep 01, 2016 at 12:06 AM

Never mind, I fixed my problem :) In case anyone was wondering, The problem was that my 3d model didn't have a collider on it, so it couldn't collide with anything.

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

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

89 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 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 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 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

How i prevent 2 obejcts with kinematic checked in both rigidbodies collide? 3 Answers

How to check if gameObject is interact with multiple colliders 1 Answer

player going through walls even though it has colliders and rigidbodies 0 Answers

How do I detect a collision between two objects using Bolt? 1 Answer

my colliders don't work properly 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