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 thevraptor · May 18, 2014 at 03:16 AM · rigidbodycollidercolliderscharacter controllerfpswalker

Colliders Not Working

Hello,

I am making a game in which you mantain a space station. I was altering the FPSWalker script so that if you start moving in one direction, you don't stop, like in real space. Before, I could collide with the space station, because it had colliders generated (that one high res space station from the nasa package). But, when I tweaked the script, I would just pass right through it. I was using Time.deltaTime for the sliding around, so has that got anything to do with it, and if so or not, how can I fix it? Thanks.

P.S. It did this with the character controller applied and being used, so I replaced it with a collider and made the script stop referencing the CC, but with the exact same results. Also, regenerating the colliders didn't work either. I even tried using a rigidbody, but with no dice.

Code:

 var speed = 6.0;
 var jumpSpeed = 6.0;
 var gravity = 20.0;
 var random : boolean;
 var slideForward : boolean;
 var slideBackward : boolean;
 var slideLeft : boolean;
 var slideRight : boolean;
 var slideUp : boolean;
 var slideDown : boolean;
 var inSpace : boolean;
 slideForward = false;
 slideBackward = false;
 slideLeft = false;
 slideRight = false;
 slideUp = false;
 slideDown = false;
 inSpace = true;

 private var moveDirection = Vector3.one;
 private var grounded : boolean = false;


 function FixedUpdate() {


 if (random == false) {
     moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
     moveDirection = transform.TransformDirection(moveDirection);
     moveDirection *= speed;
     
     if (Input.GetKey (KeyCode.Q)) {
         moveDirection.y = jumpSpeed;
         slideUp = true;
         slideDown = false;
         slideForward = false;
         slideBackward = false;
         slideLeft = false;
         slideRight = false;
     }
     
     if (Input.GetKey (KeyCode.E) ) {
         moveDirection.y = -jumpSpeed;
         slideUp = false;
         slideDown = true;
         slideForward = false;
         slideBackward = false;
         slideLeft = false;
         slideRight = false;
     }

 // sliding
     if (slideForward)
         transform.Translate(0, 0, Time.deltaTime * speed);
 
     if (slideBackward)
         transform.Translate(0, 0, -Time.deltaTime * speed);
         
     if (slideLeft)
         transform.Translate(Time.deltaTime * speed, 0, 0);
         
     if (slideRight)
         transform.Translate(-Time.deltaTime * speed, 0, 0);
         
     if (slideUp)
         transform.Translate(0, Time.deltaTime * jumpSpeed, 0);
         
     if (slideDown)
         transform.Translate(0, -Time.deltaTime * jumpSpeed, 0);
      }
 // slide boolean activators    
     if (Input.GetKey (KeyCode.W) && inSpace == true) {
         slideForward = true;
         slideBackward = false;
         slideLeft = false;
         slideRight = false;
      }
         
     if (Input.GetKey (KeyCode.S) && inSpace == true) {
         slideBackward = true;
         slideForward = false;
         slideLeft = false;
         slideRight = false;
      }
         
     if (Input.GetKey (KeyCode.D) && inSpace == true) {
         slideLeft = true;
         slideRight = false;
         slideForward = false;
         slideBackward = false;
      }
         
     if (Input.GetKey (KeyCode.A) && inSpace == true) {
         slideRight = true;
         slideLeft = false;
         slideForward = false;
         slideBackward = false;
      }
 
 moveDirection.y -= gravity * Time.deltaTime;
 }
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 Jeff-Kesselman · May 18, 2014 at 05:33 PM 0
Share

All objects that move that you also wish to collide must either have a character controller or a rigid body and a collider. $$anonymous$$ake sure all colluders are NOT set to "isTrigger" as well.

If you are moving VERY fast then the default collision detection can experience a "frame miss". This is where the object is on one side of the object in its way in one frame, and the other side in the next such that they never overlap.

You can turn on continuos collision to fix this, but recognize that it greatly increases the cost of collision detection...

https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-collisionDetection$$anonymous$$ode.html

avatar image thevraptor · May 18, 2014 at 07:38 PM 0
Share

Like I said, I tried a character controller and a rigidbody. Setting the rigidbody to continuos dynamic didn't help either, and none of the colliders are triggers. Is it a glitch, possibly? Or am I just really stupid?

1 Reply

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

Answer by thevraptor · May 19, 2014 at 01:26 AM

Problem solved, forget about it. I used a rigidbody and a capsule collider instead of a mesh collider.

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

21 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

Related Questions

Multiple Colliders 1 Answer

How to attach two colliders (i.e two or more game objects )? 1 Answer

Colliding without gravity 2 Answers

Character Controller won't collide with anything 1 Answer

When and when not to use kinematic rigidbody? 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