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 Kenned · Nov 06, 2013 at 12:53 PM · jumpinganimationcurve

Using animationcurves for controlling jump height through charactercontroller.Move()

Hey Guys :)

I'm trying to create a nicer and easier customizable flow for my jump. But I have no idea how to do this.

This is currently my code for the jump:

 case PlayerState.jumping:
             
     moveDirection = new Vector3(0,currentJumpSpeed,0);
             
     playerController.Move(moveDirection);
     currentJumpSpeed -= jumpSpeedFalloff;
             
     break;

Nothing exciting, however what I want is to control the value of the falloff with a curve :)

Any good suggestions? :)

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
3

Answer by Kenned · Nov 07, 2013 at 11:26 AM

Hey again, so with the help I got from TheValar, I ended up getting what I wanted :3 It's nothing special but I thought I'd share it anyway ^^

alt text

So this is my inspector view, and what I did was making a public animation curve along with my jump speed

Here's the code:

 if(Input.GetAxisRaw("X") >= 0.1f){
     currentState = PlayerState.jumping;
     jumpTimer = 0.0f;
 }

//-----------------------------------------------------------------

 case PlayerState.jumping:
             
     moveDirection = new Vector3(0,currentJumpSpeed,0);
             
     playerController.Move(moveDirection);
     jumpSpeedFalloff = jumpCurve.Evaluate(jumpTimer);
     currentJumpSpeed -= jumpSpeedFalloff;
     jumpTimer += Time.deltaTime;
             
     break;

I hope someone else can make use of this because this was a topic which took me a long time to understand <.<'

My curve looks like that because I'm trying to have a fast setoff, which degrades quickly, then go on to having the character more or less floating for a while, then go back to having a fast descend :3

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 Rechronicle · Oct 16, 2021 at 08:53 AM 0
Share

this will be useful! especially the animationcurve will be handy for other situation :)

and I'm bad at math, lol

avatar image
0

Answer by TheValar · Nov 06, 2013 at 02:12 PM

I've never done this but I don't see why it wouldn't be possible to do the following.

Add a public AnimationCurve variable to your controller script and edit it to your desire http://docs.unity3d.com/Documentation/Components/EditingCurves.html

Then from your script you can sample the appropriate part of the curve using jumpSpeedFalloff = curve.Evaluate(timeSinceJumpStarted); or something http://docs.unity3d.com/Documentation/ScriptReference/AnimationCurve.Evaluate.html

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 Kenned · Nov 06, 2013 at 02:40 PM 0
Share

Thanks a bunch : D I'll try it out in a few $$anonymous$$utes when I get my particle system up and running as it should :)

It sounds like it should do the trick :P

avatar image TheValar · Nov 06, 2013 at 03:35 PM 0
Share

I'd be interested in how this turns out. If you get it working you should post a video or a webplayer.

avatar image Kenned · Nov 06, 2013 at 07:15 PM 0
Share

Sure :3 I'll come back to that, we're currently working with a deadline for monday so I have quite a few elements that needs fixing, but I'll probably get to fix it later today :)

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

17 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

Related Questions

Unity3D - CharacterController Jump Issues 1 Answer

How do i code jumping for a 2d game in JS? 0 Answers

auto jumping to a platform 0 Answers

Double Jumping Occasionally Not Working 0 Answers

How to reduce moveability for player when releasing button mid-air 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