Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class test : MonoBehaviour
  6. {
  7. public float speed = 40f;
  8. public int predictionStepsPerFrame = 6;
  9. public Vector3 bulletVelocity;
  10. public Vector3 windDirection;
  11.  
  12. void Start()
  13. {
  14. }
  15.  
  16. void Update()
  17. {
  18. bulletVelocity = transform.forward * speed;
  19.  
  20. if (predictionStepsPerFrame > 0)
  21. {
  22. Vector3 point1 = transform.position;
  23. float stepSize = 1.0f / predictionStepsPerFrame;
  24. Vector3 predictedBulletVelocity = bulletVelocity;
  25. for (float step = 0; step < 10; step += stepSize)
  26. {
  27. predictedBulletVelocity += windDirection + Physics.gravity * stepSize;
  28. Vector3 point2 = point1 + predictedBulletVelocity * stepSize;
  29. Debug.DrawLine(point1, point2);
  30. point1 = point2;
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement