[ad_1]
What I am doing:
I am shifting a projectile to it is goal alongside a Bézier curve with one management level.
The projectile strikes from Remodel
A to Remodel
B with the curve created by management’s Remodel
‘s place. I am utilizing this methodology in order that I can change how the projectile’s arc or path seems relying on the enemy’s place.
The difficulty:
The projectile travels from A to B efficiently, nonetheless, my subject is relying on the curve the velocity may be inconsistent and an undesirable ‘easing’ impact can happen.
Here is an instance within the picture under. Due to management’s place, you possibly can see the wirespheres start to bunch up and smoosh collectively. Because the projectile travels from A to B, it is going to regularly transfer slower because the wirespheres grow to be nearer collectively.
Listed below are the 2 scripts I’m utilizing to perform this:
public class QuadraticCurve : MonoBehaviour
{
public Remodel A;
public Remodel B;
public Remodel Management;
public Vector3 consider(float t)
{
Vector3 ac = Vector3.Lerp(A.place, Management.place, t);
Vector3 cb = Vector3.Lerp(Management.place, B.place, t);
return Vector3.Lerp(ac, cb, t);
}
non-public void OnDrawGizmos()
{
if(A == null || B == null || Management == null)
{
return;
}
for (int i = 0; i < 20; i++)
{
Gizmos.DrawWireSphere(consider(i / 20f), 0.1f);
}
}
}
public class ProjectileAttack: MonoBehaviour
{
public QuadraticCurve curve;
non-public IEnumerator MoveTheDart()
{
// Set the goal
_curve.B.remodel.place = ImpactPosition.place;
whereas (sampleTime < 1f)
{
sampleTime += Time.deltaTime * newSpeed;
projectile.place = curve.consider(sampleTime);
yield return null;
}
}
}
What I want help with:
- I want my projectile to maneuver alongside the curve from A to B with a constant velocity no matter how the curve seems.
Thanks a lot to anybody taking the time!😊
[ad_2]