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 BluEye · Sep 03, 2012 at 02:35 AM · fallingcrouchfloorfalling-through-floor

Crouching and falling through floor

Hello,

I am using the CharacterMotor.js and FPSInputController.js (basics) as movement scripts.

I created a basic game and just want the character to crouch now.

From reading various posts this is the script I created.

 function Update ()
  {
  
    if (Input.GetKeyDown ("c"))
    {
       transform.position.y -= 0.5;
       
       transform.localScale.y = 0.25;
 
 }
 
    if (Input.GetKeyUp ("c"))
 {
 
       transform.position.y += .7;
       
       transform.localScale.y = 2.0;
 }
 }


My character starts a scale y = 2 (though 3 would be better)

I need to know how to make it so after hitting the "c" button to return to normal size (2/3) I do not fall through the floor. What do I need to fix?

Comment
Add comment · Show 7
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 Fattie · Sep 03, 2012 at 05:55 AM 0
Share

FWIW ... is your floor very flat or is it hilly ?

avatar image BluEye · Sep 03, 2012 at 06:09 AM 0
Share

It is completely flat.

I messed around with the controls a bit more and if I scale the character to Y=1 it is fine because after I release "c" (from it crouching) there really is no true crouch.

In other words while yes the character is crouching down to .25 for it to go back to 1.0 it is fine.

When it exceeds the 1.0 is when it falls through the floor because it is trying to 'grow' up and down at the same time.

If that all makes sense.

avatar image Fattie · Sep 03, 2012 at 06:18 AM 0
Share

ok so you've completely fixed the problem.

DON'T use "-=" and "+=" ...

actually just SET the values. so, set them to 1, 0.5 or whatever you want.

avatar image BluEye · Sep 03, 2012 at 06:23 AM 0
Share

I did not fix the problem because I need the character to actually resume the height of 2 or 3. I was just testing it out.

If I remove the "+ or -" the character will immediately fall through the floor.

avatar image Fattie · Sep 03, 2012 at 06:31 AM 0
Share

O$$anonymous$$ let me explain. Firstly as I say do not use the "+=" or "-=" format. Just set them using "="

then of course, you must set the values CORRECTLY.

only YOU can figure out what they should be as you have the scene in front of you.

IF IT IS FALLING THROUGH THE FLOOR, $$anonymous$$A$$anonymous$$E THE "POSITION" HIGHER.

so if you try position.y = 3, and it falls through the floor, next you should try "4"

And so on

O$$anonymous$$ ?

Good luck

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Falling through floor glitch 1 Answer

Checklist: Object or Character is falling through the floor 12 Answers

THIN objects can fall through the ground? (AMAZING SOLUTION) 2 Answers

Prevent Fallthrough with Procedural Mesh and Collider 0 Answers

Enemy falls through floor when both have collider 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