Jump to content

How to disable vehicle impact with breakable objects?


Recommended Posts

hey everyone , i have been trying to write a simple physics for my server but its been a week since im trying to do this but i cant figure it out

im trying to make objects break instantly when they are collided by a vehicle but i dont want it to affect the vehicle ( i mean , disabling the car rotating after the crash or slowing down )

ive tried onClientVehicleCollision , onClientVehicleDamage , OnClientObjectBreak , onClientObjectDamage  but i couldnt do it .

so guys can you suggest me a way to make it work?

Link to comment
1 hour ago, MrKAREEM said:

GetElementVelocity

SetElementVelocity

you can use OnClientVehicleCollision


element theHitElement, float force, int bodypart, float collisionX, float collisionY, float collisionZ, float normalX, float normalY, float normalZ, float hitElementForce, int model

The source of this event is the vehicle that collided with something

so you can get the velocity of the source

and controll the hitElement

thanks for the answer , i tried your method but it didnt work

addEventHandler("onClientVehicleCollision", root,
function(collider,force, bodyPart, x, y, z, nx, ny, nz)
    if ( source == getPedOccupiedVehicle(localPlayer) ) then
         local SX , SY , SZ = getElementVelocity ( source )
         setTimer( setElementVelocity, 100, 1, source , SX , SY , SZ )
    end
end)

i tried this if u meant to do it this way

Link to comment
1 minute ago, Behnam-Edit said:

thanks for the answer , i tried your method but it didnt work

addEventHandler("onClientVehicleCollision", root,
function(collider,force, bodyPart, x, y, z, nx, ny, nz)
    if ( source == getPedOccupiedVehicle(localPlayer) ) then
         local SX , SY , SZ = getElementVelocity ( source )
         setTimer( setElementVelocity, 100, 1, source , SX , SY , SZ )
    end
end)

i tried this if u meant to do it this way

addEventHandler("onClientVehicleCollision", root,
function(collider,force, bodyPart, x, y, z, nx, ny, nz)
local theVehicle = getPedOccupiedVehicle (localPlayer)
if (theVehicle) and (source == theVehicle) then
local SX , SY , SZ = getElementVelocity ( source )
setTimer( setElementVelocity, 100, 1, source , SX , SY , SZ )
end
end)

it's important to check if the ped in vehicle or not

  • Thanks 1
Link to comment
1 hour ago, MrKAREEM said:

addEventHandler("onClientVehicleCollision", root,
function(collider,force, bodyPart, x, y, z, nx, ny, nz)
local theVehicle = getPedOccupiedVehicle (localPlayer)
if (theVehicle) and (source == theVehicle) then
local SX , SY , SZ = getElementVelocity ( source )
setTimer( setElementVelocity, 100, 1, source , SX , SY , SZ )
end
end)

it's important to check if the ped in vehicle or not

yea but it doesnt rly affect the functionality of the script , and still not working . do you have any other ideas ? cause im sure its not gonna work with these: onClientVehicleCollision , onClientVehicleDamage , OnClientObjectBreak , onClientObjectDamage

Link to comment
5 minutes ago, Behnam-Edit said:

yea but it doesnt rly affect the functionality of the script , and still not working . do you have any other ideas ? cause im sure its not gonna work with these: onClientVehicleCollision , onClientVehicleDamage , OnClientObjectBreak , onClientObjectDamage

i think the problem not from the events

try to get the speed of the vehicle

GetElementSpeed

SetElementSpeed

because i used the event onClientVehicleCollision before but i force the velocity on the object with some maths not the vehicle

Edited by MrKAREEM
  • Thanks 1
Link to comment
1 hour ago, MrKAREEM said:

i think the problem not from the events

try to get the speed of the vehicle

GetElementSpeed

because i used the event onClientVehicleCollision before but i force the velocity on the object with some maths not the vehicle

yeah but i think the problem is from the events cause idk if u saw this in need for speed games or not but when hit a barrier or a fence or lamp post , it doesnt affect the car at all! i mean it doesnt change your vehicle speed or acceleration , i had that in mind for long time i didnt know it was possible in mta but i saw they done it in nfssa server

Link to comment
  • Moderators
16 minutes ago, Behnam-Edit said:

thanks , but can you give me an example? cause ive never worked with physical properties

Same here ?

As far as I understand of the wiki.

- You have group id's which are kind of slots you can use. I don't think you have to create them. Just use 1 for your first try.

- Assign the object models you want to change to the group 1.

- Then set the properties which you think you need to achieve your goal.

 

 

 

  • Thanks 1
Link to comment
On 12/06/2020 at 13:45, Zorgman said:

Never tried to alter the object properties but in case that won't work for some reason, a workaround would be disabling collision for those objects, wrap them in colshapes and break them onColShapeHit.

yea but that would take too much time :))

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...