Jump to content

parabolic motion


Faw[Ful]

Recommended Posts

أحلى حمودي يساعد ض1

-----

yes .. using jump script and lets the gravity play when he reach the top point.

i sow in many maps they got jump script ^^

like

  
onClientMarkerHit 
local oldp 
function example() 
oldp = getElementPosition 
if oldp ~= oldp+10 then 
setElementPosition(element,oldp+1) 
example2() 
end 
end 
  
function example2() 
newp = getElementPosition 
if newp ~= oldp+10 then 
setElementPosition(element,newp+1) 
example2() 
end 
end 
  

this is simple jump script by me .. to know the idea .. you need to edit it

so if the element was at x speed when he jump .. he will jump like parabola

Edited by Guest
Link to comment

...

Element can be an object , I can do this with a lot of standard object movement (script to move an object that follow a line), but there is another way ?

Edit : Okay ! I want to make some particles with this and a particle follow an parabolic motion not a line.

Link to comment

h1ama3d not hmody

فضحتنا -_-"

...

Element can be an object , I can do this with a lot of standard object movement (script to move an object that follow a line), but there is another way ?

Edit : Okay ! I want to make some particles with this and a particle follow an parabolic motion not a line.

see :

https://wiki.multitheftauto.com/wiki/Cli ... _functions

https://wiki.multitheftauto.com/wiki/AttachElements

Link to comment

I see three ways of doing that:

1) Like told above, create an object that can move, use attachElements on it, and shoot it away.

Easy for large distances, but you need to rely on the moveable object.

Like this resourcefor example: it uses the flowerpot vehicle to create airbombs

2) Use moveObject with some kind of easing type (maybe InBounce or OutBounce are what you need).

Harder and you would need to find the correct type for it.

3) A math function and use setElementPosition in combination with a timer or onClientRender.

You'll need to know some math for this ^^.

Link to comment
  
local theObj,time,sx,sy,fx,fy,a,b,c,ticks 
  
function handleMove() 
  if ticks==0 then ticks=getTickCount() end 
  local progress=(getTickCount()-ticks)/time 
  if progress<1 then 
    local cdist=((fx-sx)^2+(fy-sy)^2)^0.5 
    local cx,cy=sx+(fx-sx)*progress,sy+(fy-sy)*progress 
    local h=a*(-cdist/2+cdist*progress)^2+b*(-cdist/2+cdist*progress)+c 
    setElementPosition(theObj,cx,cy,h) 
  else 
    killHandler() 
  end 
end 
  
function addParabolicMovement(theObj2,time2,sx2,sy2,fx2,fy2,a2,b2,c2) 
  theObj,time,sx,sy,fx,fy,a,b,c,ticks=theObj2,time2,sx2,sy2,fx2,fy2,a2,b2,c2,0 
  addEventHandler("onClientRender",getRootElement(),handleMove) 
end 
  
function killHandler() 
  removeEventHandler("onClientRender",getRootElement(),handleMove) 
end 
  

function addParabolicMovement(element obj, int time, float sx, float sy, float fx, float fy, float a, float b, float c) 
--[[ 
obj - no comments 
time - elapsing time, in ms 
sx,sy - starting pos 
fx,fy - end pos 
a,b,c - params for y=ax^2+bx+c function, c is base height aswell 
  
]] 
  

note: if you want that obj ends up in same height as it started, make sure b is 0

EDIT:centered the func.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...