Jump to content

Dynamic Objects


DarkLink

Recommended Posts

To solve the problems with rotation, you can use getElementMatrix function. With element matrix it's easy to get coordinates of the point with the same offset from the object, no matter how it's rotated. For example, if you want to get position of point which is (2, 3, 4) from element in variable "obj", you need something like this:

local m = getElementMatrix(obj) 
local x = 2*m[1][1]+3*m[2][1]+4*m[3][1]+m[4][1] 
local y = 2*m[1][2]+3*m[2][2]+4*m[3][2]+m[4][2] 
local z = 2*m[1][3]+3*m[2][3]+4*m[3][3]+m[4][3] 

Coordinates of three vectors (m[1], m[2], m[3]) are multiplied by coordinates relative to object (2, 3, 4) and another vector (m[4], which is element position) is added to them. So if you get coordinates in this way, the script will check the same part of the object whatever its rotation is.

Link to comment
To solve the problems with rotation, you can use getElementMatrix function. With element matrix it's easy to get coordinates of the point with the same offset from the object, no matter how it's rotated. For example, if you want to get position of point which is (2, 3, 4) from element in variable "obj", you need something like this:
local m = getElementMatrix(obj) 
local x = 2*m[1][1]+3*m[2][1]+4*m[3][1]+m[4][1] 
local y = 2*m[1][2]+3*m[2][2]+4*m[3][2]+m[4][2] 
local z = 2*m[1][3]+3*m[2][3]+4*m[3][3]+m[4][3] 

Coordinates of three vectors (m[1], m[2], m[3]) are multiplied by coordinates relative to object (2, 3, 4) and another vector (m[4], which is element position) is added to them. So if you get coordinates in this way, the script will check the same part of the object whatever its rotation is.

Hmmm this is nice, I didnt know about this.. Learn something today :)

Thanks Crystal ! I should look into this later .

It should solve my problem.

assuming that if a bullet hit a dynamic object will instantly destroy it You may use onClientPlayerWeaponFire event

https://wiki.multitheftauto.com/wiki/OnC ... WeaponFire

just check if hitElement is one of the dynamic element, and if it is treat it like it was destroyed

yes thats a good solution but not perfect, and to work good with punches from players and cars.. would need more code, besides that I dont want some piece gets immediatly to destroyed state at first shot.. I would need to set element data on each piece storing the numbers of shots, and when it reaches the amount I would want.. it would go to destroyed state..

well now that I am thinking about this, I could make it .. but I would need to "ignore" object receiving shots.. because at each shot it will damaging the object.. and what I want is to control the damage by myself.. and after X shots would be destroyed, and after Y seconds would be replaced.. just need to know how to ignore shots to dynamic objects..

cancel event on player damage wont do it right? because its game mechanics.. ?

with a good work around maybe I could do it, I guess.

Thanks all of guys.

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