Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private LineRenderer lineRenderer;
- public int lineResolution;
- public float launchForce = //same que l'addforce j'pense;
- public float gravity = // same que l'editor bg
- void MakeTrajectory()
- {
- Vector3[] trajectoryPoints = new Vector3[lineResolution];
- Vector3 throwVelocity = startPoint.forward * launchForce;
- for (int i = 0; i < lineResolution; i++)
- {
- float time = i * 0.1f;
- trajectoryPoints[i] = TrajectoryPoint(startPoint.position, throwVelocity, time);
- }
- lineRenderer.positionCount = lineResolution;
- lineRenderer.SetPositions(trajectoryPoints);
- }
- Vector3 TrajectoryPoint(Vector3 origin, Vector3 velocity, float time)
- {
- float x = velocity.x * time;
- float y = velocity.y * time + 0.5f * gravity * time * time;
- float z = velocity.z * time;
- return new Vector3(x, y, z) + origin;
- }
Advertisement
Add Comment
Please, Sign In to add comment