Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Rovalin · Jan 07, 2013 at 03:30 AM · scripting problemcharacter controllercrouch

Help with crouch script!

I have this crouch script I got from this link,

http://forum.unity3d.com/threads/48187-scale-character-controller-but-not-player

Here is the script,

 var controller : CharacterController;
  
  
 function Update ()
 {
    if (Input.GetKey   ("c")) {
       controller.height = 0.5;
       controller.center = 0.25;
    } else {
       controller.height = 2.0;
        controller.center= 0.5;
    }
    }

It's supposed to shrink the character controller capsule, so that it can go under objects. But I keep getting this, "Cannot convert 'float' to 'UnityEngine.Vector3" I'm not sure what is means.

I know the problem is with those controller.center pieces. But they are really important because they keep the character from sinking into the ground. Thanks for reading, this crouch has been bugging me for quite some time.

-Rov

Comment
Add comment
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

2 Replies

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

Answer by jogo13 · Jan 07, 2013 at 03:58 AM

controller.center is a Vector3 so it will need to be reassigned in the form of a Vector3 (x,y,z)

 //i'm guessing you want to just change the y so i keep the current x and z
 controller.center = Vector3(transform.position.x, 0.25, transform.position.z);
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 Maulik2208 · Jan 07, 2013 at 05:04 AM

I think all you need is this just go to this and enjoy ------> Run & Crounch Script For Player

Don't forget to mark the answer if Found useful.....Cheers.....

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 AlucardJay · Jan 07, 2013 at 06:21 AM 1
Share

Excellent link ! I used this for the OPs last question : http://answers.unity3d.com/questions/374157/character-controller-slide-action-script.html

I have seen other questions with people having trouble with the character collider falling through the terrain, I personally have never seen nor had this problem, search for these other questions to see how other users fixed the problem.

avatar image AlucardJay · Jan 07, 2013 at 07:10 AM 1
Share

As I said, have seen this problem in alot of questions, but no real definitive answer. The main issue seems to be that the colliders are not correctly set up :

http://answers.unity3d.com/questions/17779/character-model-sinks-through-floor.html

http://answers.unity3d.com/questions/305913/first-person-character-falls-through-floor.html

http://answers.unity3d.com/questions/312147/crouching-and-falling-through-floor.html

http://answers.unity3d.com/questions/61791/character-controller-falls-through-floor.html

http://answers.unity3d.com/questions/topics/falling-through-floor.html

avatar image Rovalin · Jan 18, 2013 at 10:29 PM 0
Share

Thanks for the help, but I think this crouching script doesn't fit my existing script to well. I've decided to just disable the object's collider so I can slide under it, ins$$anonymous$$d of actually shrinking the player. Thanks for all the help though! If I ever need to do a crouch script, I'll certainly know how!

-Rov

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

11 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Why is one prefab's character controller "Radius" and "Height" so much bigger than the others? 0 Answers

Changeing Walk script to always move 1 Answer

Keep Player Crouching 2 Answers

Merry Fragmas Character Controller for Unity 5 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