Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class test : MonoBehaviour
- {
- public float speed = 40f;
- public int predictionStepsPerFrame = 6;
- public Vector3 bulletVelocity;
- public Vector3 windDirection;
- void Start()
- {
- }
- void Update()
- {
- bulletVelocity = transform.forward * speed;
- if (predictionStepsPerFrame > 0)
- {
- Vector3 point1 = transform.position;
- float stepSize = 1.0f / predictionStepsPerFrame;
- Vector3 predictedBulletVelocity = bulletVelocity;
- for (float step = 0; step < 10; step += stepSize)
- {
- predictedBulletVelocity += windDirection + Physics.gravity * stepSize;
- Vector3 point2 = point1 + predictedBulletVelocity * stepSize;
- Debug.DrawLine(point1, point2);
- point1 = point2;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement