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
0
Question by Bryangs · Nov 30, 2016 at 10:15 PM · c#scripting problemfirst person controllerflydoesnt

Character refuses to fly

Hey guys, i am trying to make the player fly, but i can't make it work! I am using the Standard First Person Character, and i am trying to make him be able to fly when he enter the water so he will not be traped or something. The problem i am having is that he just doesn't fly. If i add my script to a cube or anything else, when i press space i can make them fly, but not my character! I tried removing it's scripts but still it doesn't go. Someone know why? Can you help me?

This is my script, you can test it if you want:

 using UnityEngine;
 using System.Collections;
 
 public class Fly : MonoBehaviour
 {
     bool JumpPressed = false;
     public float jumpAccelleration = 3;
 
 
     void Update()
     {
         if (!JumpPressed)
             JumpPressed = Input.GetKey(KeyCode.Space);
     }
     void FixedUpdate()
     {
         if (JumpPressed) GetComponent<Rigidbody>().AddForce(new Vector3(0, jumpAccelleration, 0), ForceMode.Impulse);
         if (JumpPressed) JumpPressed = false;
 
 
     }
 }

Comment
Add comment · Show 1
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 roman_sedition · Dec 05, 2016 at 12:39 AM 0
Share

Is your acceleration high enough? Remove gravity off your character, you should see yourself levitate when you press space.

2 Replies

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

Answer by tbenner · Dec 03, 2016 at 07:43 AM

I'll take a stab in the dark, but did you change the mass of your character? If the mass is too high, then the acceleration value probably would not have any effect. Since you say it works on cubes and you have removed all other scripts, I would compare the properties between a standard cube and your character.

Comment
Add comment · Show 11 · 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 Bryangs · Dec 04, 2016 at 03:51 AM 0
Share

Yeah, i changed to see that too and it still doesn't work.

avatar image roman_sedition Bryangs · Dec 04, 2016 at 04:10 AM 0
Share

You don' have the character's RigidBody set to kinematic right?

avatar image Bryangs roman_sedition · Dec 04, 2016 at 02:37 PM 0
Share

No, normal Rigidbody. That's why i don't have any idea of what is happening =\

avatar image FlightOfOne · Dec 04, 2016 at 06:09 PM 0
Share

It is possible that scripts on the Standard Character controller is interfering with your script. You may have to disable the script(s) just prior to flying, and re-enable after landing back.

avatar image roman_sedition FlightOfOne · Dec 04, 2016 at 11:39 PM 0
Share

It's a funny coincidence that you are commenting on this topic, given your user name.

avatar image FlightOfOne roman_sedition · Dec 05, 2016 at 03:21 AM 0
Share

Hah! that's funny, I didn't noticed until you mentioned it.

avatar image Bryangs FlightOfOne · Dec 05, 2016 at 12:03 AM 0
Share

I am going to try literally disabling everything again, removing everything that i can until that prefab is literally a capsule with no mesh and a camera.

avatar image FlightOfOne Bryangs · Dec 05, 2016 at 03:21 AM 0
Share

Yea, that would be the best approach, disable all, and start enabling one at a time, until it breaks. If I remember correctly, I ran into some similar issues, with Unity Character controller. I know they provide you with two types of controllers, physics based and non physics based. So, if you are using the physics one, it's possible to have issues with other scripts.

Show more comments
Show more comments
avatar image Bryangs · Dec 05, 2016 at 07:27 PM 0
Share

Okay, i am going to do the following:

For now, i am going to do as you said, and i am going to make another C# script from zero. I am going to disable all the scripts that the character have when he is underwater, and add ONLY the water mode script. I can add movement later.

$$anonymous$$y problem is, as i said, make the movement (i am not that good at using vertical and horizontal) and i am almost sure i am going to have some error if i disable all them at once... Anyway, i think this question is "solved". Could you make your comment as answer or something? Thanks.

avatar image
0

Answer by Shrikky23 · Dec 05, 2016 at 03:51 PM

One different solution would be to send the Jumppressed bool to the character controller script. Add your condition in their script. That should make their script take your conditions into account.

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

253 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 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 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 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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to disable MouseLook in ingame pause. 1 Answer

Enable a component after a specific amount of time? 4 Answers

Relative AddForce 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