$begingroup$

  • I am utilizing Unity’s newest Splines package deal(v2.5) to maneuver a projectile throughout a spline with velocity. It really works completely and the projectile strikes throughout the spline to it is goal with linear velocity.

  • However I would prefer to make it look even higher by making it behave a bit extra realistically. Possibly somebody smarter than me can articulate how projectiles transfer higher, however basically, I feel when a projectile is thrown it ought to have a burst of velocity firstly and start to rise slower because it reaches its peak peak. Then because it begins to fall it ought to step by step start to fall quicker.

  • I would like to make use of math to perform this, quite than one thing like an animation curve. The reason being as a result of generally enemies will likely be in numerous positions. So, the spline will look totally different relying on the enemy’s place.


Here is the code I am utilizing:

public SplineContainer spline;
public float velocity;
public float distancePercentage;
public float splineLength;
    

    
non-public IEnumerator MoveTheProjectile()
{
    // Transfer the projectile throughout the spline
    whereas (distancePercentage < 1f)
    {
        distancePercentage += velocity * Time.deltaTime / splineLength;
        currentPosition = spline.EvaluatePosition(distancePercentage);
        projectile.remodel.place = currentPosition;
        
        yield return null;
    }
}

Since I am already utilizing a velocity variable to maneuver the projectile, I feel implementing this needs to be potential.
Is anybody capable of please help me with a technique of fixing the velocity of the projectile to be extra reasonable? Thanks a lot!😊

$endgroup$

3