AnimationCurve for movement, does it feel good?

So yesterday I posted my theory that using curves would make for movement that felt better. My idea went that with Unity, AnimationCurve would be the ideal way to do just that. So today I tried it out to see how it would feel. I made a script that got the current curve position depending on if you pressed up or not. So did it work? Did it feel good? Kinda, kinda not…

I mainly experimented with most basic quadratic equations as they seemed to work the best with movement.

Curve1
Curve1

Using this curve felt nice accelerating because it made it both feel responsive yet natural. However decelerating it felt like moving on ice and just awkward.

Curve2
Curve2

Curve 2 got the opposite instead, accelerating felt like running on ice while decelerating it felt quite smooth and natural.

So discribing this there seems to be one logicial conclusion. Use the first for accelerating and the second for decelerating. This would work rather well if the transition happened but what if it the player stopped moving in the middle of it?

Weird curve
Woops

Yeaahh. Having this in the movement system would fee really awkard and be very unatural. While it is possible get it be better aligned it’s a pretty big chance that it would need a lot of work and I think more elegant solutions can be made. The code i made also was made for a keyboard while the game is supposed to be for a gamepad so that’s another problem. I do however already have an idea how it could be made so hopefully I can show it soon!

If anyone is curious to test the code I made themselves I’ve provided the Unity C# code below.

using UnityEngine;
using System.Collections;

public class HorseCurveMovement : MonoBehaviour {

public float currentSpeed;

public float maxSpeed;
public float acceleration;
public float deceleration;
public AnimationCurve movement;

// Update is called once per frame
void Update () {

// Moves the pointer towards or away from the max speed
if(Input.GetAxisRaw(“Vertical”) == 1)
{
currentSpeed += Time.deltaTime * acceleration * Input.GetAxis(“Vertical”);
}
else
{
currentSpeed -= Time.deltaTime * deceleration;

}
currentSpeed = Mathf.Clamp01(currentSpeed);

// Moves the character forward
transform.Translate(movement.Evaluate( currentSpeed) * maxSpeed*Time.deltaTime*Vector3.forward);
}
}

Advertisements
AnimationCurve for movement, does it feel good?

One thought on “AnimationCurve for movement, does it feel good?

  1. […] The second was the prototype i tested AnimationCurves on. Here their opinions varied quite differently from my own conclusions. While my conclusion was that a sharp turn towards the goal speed with both accelerating and decelerating they felt different. They felt having a slow start felt kinda nice but kinda weird when it get towards max speed so they felt this curve felt the best and most unique for our character. […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s