AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   X Y Problem Projectile motion (https://forums.alliedmods.net/showthread.php?t=332608)

Natsheh 05-22-2021 11:51

X Y Problem Projectile motion
 
I am trying to code a mortar device to target enemies behind a wall or not behind anything, so far i am failing bad with the calculations...

Knowing the two kinematics formulas that i do need to use they're..

  • Velo (Final) = Velo (Initial) + ( [acceleration or gravity] * time )
  • distance = Velo(Initial) * time + 0.5 * [acceleration or gravity] * tiime ^ 2.0


Here's the code where i am trying to calculate the initial velocity in order for the projectile to bypass the wall or to hit its target.

code



How am i calculating the velocity ( iknow its wrong i had change it many times lol )

opsy


Any help is appreciated !!!

Some other formulas :-
to find the initial speed and/or find the angle!
  • Vi = ( X * g / sin( 2 * angle ) )
  • angle = 0.5 * arcsin ( ( (g * x ) / Vi^2.0 ) )
  • times = X / (Vi * cos (angle))

DEFINITION OF characters :-

Vi = Initial Velocity
X = Distance in the x axis
angle = the angle of the XY Plane
g = Gravity which is 800unit/s^2 for the goldsrc



Similar to my problem

OrangePeel 05-24-2021 22:14

Re: X Y Problem Projectile motion
 
1 Attachment(s)
this stock is from DSHGFHDS.
"Hoffset" is "fWallHeight", u can try it.
PHP Code:

stock ParabolicMotion(iEntityFloat:end[3], Float:Hoffset)
{
    new 
Float:start[3], Float:velocity[3], Float:gravityFloat:YvelocityFloat:Xvelocity
    pev
(iEntitypev_originstart)
    
pev(iEntitypev_gravitygravity)

    new 
Float:origin[2][3]
    for(new 
02++)
    {
        
origin[0][i] = start[i]
        
origin[1][i] = end[i]
    }

    new 
Float:Acceleration gravity 0.0 gravity*800.0 800.0
    
new Float:Leveldistance get_distance_f(origin[0], origin[1])

    if(
end[2]-start[2]+Hoffset >= 0.0)
    {
        
Yvelocity floatsqroot(2.0*Acceleration*(end[2]-start[2]+Hoffset))
        
Xvelocity Leveldistance/(Yvelocity/Acceleration+floatsqroot(2.0*Hoffset/Acceleration))
    }
    else 
Xvelocity Leveldistance/floatsqroot(2.0*(start[2]-end[2])/Acceleration)

    
xs_vec_sub(origin[1], origin[0], velocity)
    
xs_vec_div_scalar(velocityLeveldistance/Xvelocityvelocity)
    
velocity[2] = Yvelocity

    set_pev
(iEntitypev_velocityvelocity)


Attachment 189394

Natsheh 05-25-2021 06:00

Re: X Y Problem Projectile motion
 
1 Attachment(s)
thanks for your time really appreciated it, but this is not what i want!

also i am not sure how are you calculating the direction in your stock doesn't seem like you're caring about the direction at all ?

and here's a pic explaining what actually is happening :)

Attachment 189402

OrangePeel 05-26-2021 00:18

Re: X Y Problem Projectile motion
 
Quote:

Originally Posted by Natsheh (Post 2747762)
thanks for your time really appreciated it, but this is not what i want!

also i am not sure how are you calculating the direction in your stock doesn't seem like you're caring about the direction at all ?

and here's a pic explaining what actually is happening :)

Attachment 189402

what u want is create a projectile to hit a target behind a wall. do I have any misunderstanding?
then the projectile should do a parabolic motion to bypass the wall.
i'm not the author of this stock, so i can't help u to understand the calculation:oops:

Natsheh 05-26-2021 07:34

Re: X Y Problem Projectile motion
 
Quote:

Originally Posted by OrangePeel (Post 2747833)
what u want is create a projectile to hit a target behind a wall. do I have any misunderstanding?
then the projectile should do a parabolic motion to bypass the wall.
i'm not the author of this stock, so i can't help u to understand the calculation:oops:

yes, and no its not just a parabolic motion that i need, its actually called trajectory

fysiks 05-26-2021 23:37

Re: X Y Problem Projectile motion
 
Quote:

Originally Posted by Natsheh (Post 2747861)
yes, and no its not just a parabolic motion that i need, its actually called trajectory

Parabolic motion is a type of trajectory. The trajectory of any object that is subject only to gravity (i.e. not powered and has little to no air resistance) will be parabolic. If you have a powered projectile, the trajectory will not be parabolic until there is no longer any propulsive force. When the propulsive force stops, the trajectory will become parabolic because it will only be acted upon by gravity.


All times are GMT -4. The time now is 02:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.