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 /
avatar image
1
Question by SpinoRex · Sep 17, 2017 at 04:42 AM · collision detectioncharacter controllercollision issuescollision-error

Character Controller collisions on older version no longer working?

So I just started making a game in Unity and was following a tutorial from a series by Sebastian Lague (https://www.youtube.com/watch?v=qITXjT9s9do) for a 3rd person game that was uploaded on Dec. 14, 2016. I used a Character Controller component on my player character and added on a script for collisions that worked in the video, but not for me. I've tried to search this up and seen people who have had some troubles with Character Controllers, but no answers. Yes, I could just use other methods of collision detection, but I would at least like to know why this used to work and no longer does (I have checked the script, nothing looks different than the video's one except for variable values; if I am wrong about that, please correct me).

Script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerController : MonoBehaviour {
 
     public float walkSpeed = 1;
     public float runSpeed = 2;
 
     public float turnSmoothTime = .25f;
     float turnSmoothVelocity;
 
     public float speedSmoothTime = .1f;
     float speedSmoothVelocity;
     float currentSpeed;
 
     Animator animator;
     Transform cameraTarget;
     CharacterController controller;
 
     void Start () {
         animator = GetComponent<Animator> ();
         cameraTarget = Camera.main.transform;
         controller = GetComponent<CharacterController> ();
     }
 
     void Update () {
 
         Vector2 input = new Vector2 (Input.GetAxisRaw ("Horizontal"), Input.GetAxisRaw ("Vertical"));
         Vector2 inputDir = input.normalized;
 
         if (inputDir != Vector2.zero) {
             float targetRotation = Mathf.Atan2 (inputDir.x, inputDir.y) * Mathf.Rad2Deg + cameraTarget.eulerAngles.y;
             transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(transform.eulerAngles.y, targetRotation, ref turnSmoothVelocity, turnSmoothTime);
         }
 
         bool running = Input.GetKey (KeyCode.LeftShift);
         float targetSpeed = ((running) ? runSpeed : walkSpeed) * inputDir.magnitude;
         currentSpeed = Mathf.SmoothDamp (currentSpeed, targetSpeed, ref speedSmoothVelocity, speedSmoothTime);
 
         Vector3 velocity = transform.forward * currentSpeed;
 
         controller.Move (velocity * Time.deltaTime);
 
         float animationSpeedPercentage = ((running) ? 1 : .5f) * inputDir.magnitude;
         animator.SetFloat ("speedPercentage", animationSpeedPercentage, speedSmoothTime, Time.deltaTime);
 
     }
 }
 

alt text

charactercontroller.png (9.9 kB)
Comment
Add comment · Show 4
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 hexagonius · Sep 17, 2017 at 05:41 AM 0
Share

What is not working?

avatar image SpinoRex hexagonius · Sep 17, 2017 at 01:47 PM 0
Share

The character simply goes right through objects like it had no collision system.

avatar image bananatrooper52 · Sep 17, 2017 at 08:15 AM 1
Share

Did you remember to add a collider on the object you want the character controller to stand on?

avatar image SpinoRex bananatrooper52 · Sep 17, 2017 at 02:06 PM 0
Share

If you're talking about the objects I want collisions with, it works great once I added box or mesh colliders (depending on objects)! Do you by any chance know why it worked without them in the video? If I saw something wrong though, please correct me. I was using the "Prototyping" models in the Unity Standard Assets.

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by tormentoarmagedoom · Sep 18, 2017 at 08:00 AM

Good day @SpinoRex !

I don't know if something changed or the update does this, but i had the same problkem with some collisions. I had to "remake" some of the colliding objects. After finishing i was thinking, and realized was a RigidBody problem.

Read again the OntriggerEnter definitiuon, and check if there is/isn't a RigidBody where it should be

Please: Mark the answer, Upvote it, and when solved, close the question.

PD: If need more help, jkust ask using @tormentoarmagedoom

Bye ! :D

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

71 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

Related Questions

Problem with collision detection after upgrading to Unity 2019.2.9f1, 0 Answers

How to Check if you are Colliding with more than one object with the same tag? 2 Answers

Why is my trigger colliding with another trigger? 2 Answers

Enemy Ai Damage gets done multiple times 0 Answers

Bullets go through collider even with continuous collision detection! 0 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