what is the formula for Predictive aim ?

Get help using Construct 2

Post » Mon Sep 15, 2014 10:46 am

hi
i can not use turret behavior so i made my own turret system ...
but i need for Predictive aim system
what is the formula ?
i have variables like :
- projectile speed
- turret and target position and angle
and i know my target moving or not
...
thanks
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Mon Sep 15, 2014 11:00 am

Hope this helps:

Code: Select all
function aimAngle(target, bulletSpeed) {
    var rCrossV = target.x * target.vy - target.y * target.vx;
    var magR = Math.sqrt(target.x*target.x + target.y*target.y);
    var angleAdjust = Math.asin(rCrossV / (bulletSpeed * magR));

    return angleAdjust + Math.atan2(target.y, target.x);
}


At this link is an even more detailed formula:
http://www.reddit.com/r/gamedev/comment ... la/c7vbu2j
B
44
S
10
G
8
Posts: 437
Reputation: 6,463

Post » Mon Sep 15, 2014 11:06 am

Ubivis wrote:Hope this helps:

Code: Select all
function aimAngle(target, bulletSpeed) {
    var rCrossV = target.x * target.vy - target.y * target.vx;
    var magR = Math.sqrt(target.x*target.x + target.y*target.y);
    var angleAdjust = Math.asin(rCrossV / (bulletSpeed * magR));

    return angleAdjust + Math.atan2(target.y, target.x);
}

thanks ..
but what is "target.vy and target.vx" ?
and construct 2 dont have atan2 ... (i think i must use "angle" but how ?!)
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Mon Sep 15, 2014 11:11 am

I edited my post above with an formula that is language independent, I just googled the formula for you ;)
B
44
S
10
G
8
Posts: 437
Reputation: 6,463

Post » Mon Sep 15, 2014 11:37 am

Ubivis wrote:I edited my post above with an formula that is language independent, I just googled the formula for you ;)

thanks .. but i know that .. i whant the formula in construct 2 ...
if anyone can change the formula to construct 2 please do it .. ?
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Mon Sep 15, 2014 1:45 pm

It seems to be (i'm not sure):
target.vy = y-coordinate of target after 1 frame (minimal game graphic update)

magR = distance beetween turret and target.
B
5
S
1
Posts: 22
Reputation: 421

Post » Mon Sep 15, 2014 3:26 pm

Vx and vy are the x and y velocities of the target.
Instead of atan2(y,x) you can use angle(0,0,x,y)
B
91
S
31
G
103
Posts: 5,241
Reputation: 67,768

Post » Tue Sep 16, 2014 7:21 am

R0J0hound wrote:Vx and vy are the x and y velocities of the target.
Instead of atan2(y,x) you can use angle(0,0,x,y)

how do i calculate Vx and vy ?
i still looking for formula ...
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Tue Sep 16, 2014 3:50 pm

Depending on what movement behavior the target uses they can have an expresion to get velocityX and velocityY, or Speed and angleOfMotion. You can convert the latter to vx,vy with:

vx = speed * cos(angleOfMotion)
vy = speed * sin(angleOfMotion)
B
91
S
31
G
103
Posts: 5,241
Reputation: 67,768

Post » Tue Aug 25, 2015 12:48 am

@R0J0hound trying to get predictive aim working, but it's not...what am I doing wrong?

https://dl.dropboxusercontent.com/u/362 ... t_aim.capx
B
89
S
29
G
14
Posts: 1,159
Reputation: 15,038

Next

Return to How do I....?

Who is online

Users browsing this forum: ultrafop and 1 guest