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 Griffo · Dec 02, 2012 at 02:08 PM · character controllerray cast

Character Controller

Hi, can you turn off ray cast detection on a character controller ?

The problem is I have a enemy as in the pictures below with a character controller for controlling his movements when looking for the player and a box collider for ray cast detection from the players weapons, the reason I'm using a box collider is so when the enemy is in different positions I resize the box collider to suite his position.

The problem is if I resize the character controller just under the box collider size he gets stuck on little obstacles like roadside curbs, so I have to resize the character controller just bigger than the box collider so he will walk/run over obstacles, this then causes problems detecting the box collider, thats why I wanted to turn off detection of the character controller so the ray cast will pass through to the box collider.

Pic01 Pic02

grab01.png (113.9 kB)
grab02.png (161.8 kB)
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 fafase · Dec 02, 2012 at 02:22 PM 0
Share

Can you tell a little more? Do you mean you want to cast a ray from the guy but it hits the collider? Then use a layer mask.

Else, let us know.

Other way is to add an empty game object outside the collider attached to the player and use it to cast the ray.

avatar image Griffo · Dec 02, 2012 at 02:25 PM 0
Share

Hi fafase, I'll add more information to my question.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by difd 9999 · Dec 02, 2012 at 02:33 PM

You could make a script so that when your enemy is still it will resize and likewise srink when moving ps. Accept answers if you want more answers

Comment
Add comment · Show 1 · 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 Griffo · Dec 02, 2012 at 02:35 PM 0
Share

Hi, I don't want to turn it off, only ray cast detection hitting it.

avatar image
0

Answer by fafase · Dec 02, 2012 at 06:12 PM

Is you issue to lower the CC when crawling?

Fact is you cannot rotate the CC but you can alter its height using UnityEngine; using System.Collections;

 public class CCScript : MonoBehaviour {
     CharacterController cc;
 
     
     void Start () {
         cc =GetComponent<CharacterController>();
     }
     void Update () {
         if(Input.GetKeyDown(KeyCode.Z)){
             cc.height = 0.5f;
                var rotation = Quaternion.identity;
             rotation *= Quaternion.Euler(90, 0, 0); // this add a 90 degrees Y rotation
             transform.rotation = Quaternion.Slerp(transform.rotation, rotation, 1);
         }
         if(Input.GetKeyDown(KeyCode.E)){
             cc.height = 2f;
             var rot = Quaternion.identity;
             rot *= Quaternion.Euler(0, 0, 0); 
             transform.position = new Vector3(transform.position.x,transform.position.y+1,transform.position.z);
             transform.rotation = Quaternion.Slerp(transform.rotation, rot, 1);
         }
     }
 }

This is a very bad little script that when you press Z, the capsule goes lying down and the collider goes small enough. Pressing E, the collider gets back to normal and so does the capsule. In my example since I am not using any kind of animation, everything happens at once and I need to set the position up a little so that the CC does not go down through the ground.

I reduce the collider as you cannot rotate it.

It might not be what you need but maybe it will lead you somewhere.

Comment
Add comment · Show 1 · 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 Griffo · Dec 02, 2012 at 07:58 PM 0
Share

Thanks for the input, the way I've gone is to remove the box collider and resize the character controller when in the attack positions.

Pic01 Pic02

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

12 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

Related Questions

How to be tangent with the ground without a character controller? 2 Answers

How to get my character to collide with objects 1 Answer

character controller height transition 0 Answers

Does anyone know how to stop the character from rolling around? 1 Answer

Character Controller doesn't always follow it's parent position? 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