Hello, dear community!
----------------------
I would like to create a script for a bot to be able to shoot not at enemy's current position, but at the position where it will be in a second or two. I would like to ask for your help in evaluating my logic, whether it is correct. I am attaching 2 paint pictures for a better explanation.
----------
Script steps:
1. determine enemy's movement speed (maybe?done by: getting enemy's velocity.magnitude ?)
2. determine enemy's vector (maybe?done by: store enemy's transform.position from last frame and check it against current position ?)
3. determine enemy's distance (done by: reading enemy's transform.position)
4. knowing our speed (done)
5. knowing the speed of our projectile (done)
----------
equation, where "x" - is the point enemy will be in "y" seconds
x = enemy's speed* enemy's movement vector * y
equation, where "edist" - is the distance between us and the enemy
edist = x(current) - x(previous)
equation, where "pspeed" - is the speed of our projectile
pspeed = edist/y
because
pspeed = constant say 10 float
y = constant 2 seconds
----------
if (full "edist" distance can be covered in full "y" seconds){
shoot at "x" ?
}
Does it make sense?
[1]: /storage/temp/50676-firing1.png
[2]: /storage/temp/50677-firing2.png
↧