- Home /
Question by
kewalkishang · Nov 09, 2017 at 01:34 PM ·
animationspline
Get a hovering effect ( up and down ) for a gameobject moving on a spline .
we have a gameobject moving on a spline but we want it to have a smooth up down motion as it moves along the spline path . I tried putting it as a child of another gameobject with an up down animation attached to it , but it is not smooth . any suggestion ?
Comment
Answer by UnityVeris · Nov 10, 2017 at 03:26 AM
To create a smoothly oscillating effect like what you described, try something like this, and changing the values to suit your situation:
public float currentpos = 0f;
public float accel = 0.1f;
public float speed = 0.1f;
public void ChangeSpeed(){
if (currentpos > 0){
accel -= speed;
}else{
accel += speed;
}
currentpos += speed;
}