Raised This Month: $ Target: $400
 0% 

X Y Problem Projectile motion


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-22-2021 , 11:51   X Y Problem Projectile motion
Reply With Quote #1

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
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 05-22-2021 at 12:26.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old 05-23-2021, 23:46
OrangePeel
This message has been deleted by OrangePeel. Reason: request by Natsheh
Old 05-24-2021, 13:06
Natsheh
This message has been deleted by Natsheh. Reason: Thanks
OrangePeel
Junior Member
Join Date: Aug 2019
Old 05-24-2021 , 22:14   Re: X Y Problem Projectile motion
Reply With Quote #2

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)

Name:  0e3d8213632762d0524f4615a2ec08fa503dc67d_gaitubao_620x280.jpg
Views: 204
Size:  9.3 KB

Last edited by OrangePeel; 05-24-2021 at 22:22.
OrangePeel is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-25-2021 , 06:00   Re: X Y Problem Projectile motion
Reply With Quote #3

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

Name:  20210525125129_1.jpg
Views: 328
Size:  74.5 KB
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 05-25-2021 at 06:01.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OrangePeel
Junior Member
Join Date: Aug 2019
Old 05-26-2021 , 00:18   Re: X Y Problem Projectile motion
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
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

Last edited by OrangePeel; 05-26-2021 at 00:29.
OrangePeel is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-26-2021 , 07:34   Re: X Y Problem Projectile motion
Reply With Quote #5

Quote:
Originally Posted by OrangePeel View Post
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
yes, and no its not just a parabolic motion that i need, its actually called trajectory
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-26-2021 , 23:37   Re: X Y Problem Projectile motion
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
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.
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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