arithmetic – Unity – Simulate Velocity For A Projectile Shifting Alongside A Spline

arithmetic – Unity – Simulate Velocity For A Projectile Shifting Alongside A Spline

[ad_1]

arithmetic – Unity – Simulate Velocity For A Projectile Shifting Alongside A Spline – Recreation Improvement Stack Change







Recreation Improvement Stack Change is a query and reply website for skilled and impartial sport builders. It solely takes a minute to enroll.

Signal as much as be a part of this neighborhood

Anyone can ask a query

Anyone can reply

The perfect solutions are voted up and rise to the highest

Requested

Seen
2 instances

$begingroup$

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

  • 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 primarily, I feel when a projectile is thrown it ought to have a burst of pace initially and start to rise slower because it reaches its peak top. Then because it begins to fall it ought to progressively start to fall sooner.

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


This is the code I am utilizing:

public SplineContainer spline;
public float pace;
public float distancePercentage;
public float splineLength;
    

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

Since I am already utilizing a pace variable to maneuver the projectile, I feel implementing this needs to be attainable.
Is anybody in a position to please help me with a technique of adjusting the pace of the projectile to be extra real looking? Thanks a lot!😊

$endgroup$

You could log in to reply this query.

lang-cs

 

[ad_2]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Scroll to Top