I been reading a bit about slerping, and I’m not sure I can use it in my javascript, or exactly how it’s working for calculations. I’m using a script for camera movement, RTS, and when you move the camera to the defined boundries, it starts scrolling, at the speed of a given variable [scrollSpeed], but this feels jerky, it takes you to full speed instantly, and it’s hard to do precise movement. Is there a way to put like a function onit, so it starts out slow, and then builds in speed, til reaching the defined speed?

```
myVector = (Vector3(mySpeed,0,0) * scrollSpeed * Time.deltaTime);
```

using UnityEngine;
using System.Collections;
public class SmoothMover : MonoBehaviour
{
//animation curve is nice for any y=f(x) to use in gameplay
//use smooth function here. check it in inspector for graphic representation
public AnimationCurve MoveSpeed = new AnimationCurve(new Keyframe[]
{
new Keyframe(0.0f, 0.0f, 0.0f, 0.0f),
new Keyframe(0.3f, 0.1f, 1.0f, 1.0f),
new Keyframe(0.5f, 0.5f, 2.0f, 2.0f),
new Keyframe(0.7f, 0.9f, 1.0f, 1.0f),
new Keyframe(1.0f, 1.0f, 0.0f, 0.0f)
});
//coordinates where we move from and to
public Vector3 MoveFrom = Vector3.zero;
public Vector3 MoveTo = Vector3.right * 10f;
//object that we move
Transform movingObj;
void Start()
{
//simple create here a primitive to check how it works
movingObj = GameObject.CreatePrimitive(PrimitiveType.Sphere).transform;
}
void Update()
{
//the main line of code 8)
//Vector3.Lerp gives us a point between two points on needed offset in 0..1 range
//MoveSpeed.Evaluate returns a y=f(x) from smooth function
//Mathf.PingPong simple returns x that
//changes in time from 0 to 1, then to 0, then to 1 etc
movingObj.position = Vector3.Lerp(MoveFrom, MoveTo, MoveSpeed.Evaluate(Mathf.PingPong(Time.time * 0.5f, 1f)));
}
}

links