Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name ARTILLERY_FINAL
- @inputs V1:vector Cannon:entity Speed Type Gyro
- @outputs Pitch Yaw Distance
- @persist D V21:vector V22:vector Sin Osin RX RY
- @trigger
- #My Final Artillery:
- #Input The Vector of the target and the Entity of the (to judge the firing point)
- #You can easily change the entity input to a vector of the firing point,
- #and then replace line 17 with "V22 = vec(vec2(V2))" assuming V2 is the input
- #Input the Speed of the Porjectile (in units/sec)
- #Input the type, as this equation uses Sine, there are 2 solutions for each distance,
- #By Setting Type to 0, a shallower shorter path is taken
- #By Setting Type to 1, a higher, longer path is taken (more "Artillery-like")
- #The expression will output Pitch of Firing, Yaw (what bearing to aim at) and the Distance between gun and Target)
- #This expression uses equations from Wikipedia's "Trajectory of a projectile" page
- V21 = vec(vec2(V1))
- V22 = vec(vec2(Cannon:pos()))
- D = V21:distance(V22)
- Sin=asin((0.5*D)/(Speed^2))
- Osin=180-Sin
- if(Type){
- Pitch = 0.515*Osin}
- else{
- Pitch = 0.5*Sin}
- Distance = D
- RX = (V22:x()) - (V21:x())
- RY = (V22:y()) - (V21:y())
- Yaw = atan(RY/RX)-(Gyro-141.24)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement