DiosSasuke Posted May 22, 2018 Share Posted May 22, 2018 ¿how do I make the explosion and the object appear where I look? here I leave my code objs = {} addCommandHandler ( "explosion", function ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) local rx, ry, rz = getElementRotation ( thePlayer ) local origX, origY, origZ = getElementPosition ( thePlayer ) local mat = Matrix.create ( x, y, z+20, rx, ry, rz, origX - 30,origY+30,origZ) local forward = ( Matrix.getForward ( mat ) * 4) local pos = ( Matrix.getPosition ( mat ) + forward ) setTimer (createExplosion, 2000, 1,x+10, y, z, 11) objs[thePlayer] = createObject(751, pos) local newZ = origZ +0 moveObject( objs[thePlayer], 2000, origX, origY, origZ) end ) Link to comment
Addlibs Posted May 23, 2018 Share Posted May 23, 2018 (edited) A lot of this code doesn't make sense. You should try commenting on it to show your intention as its difficult to find out what you were trying to do. objs = {} addCommandHandler ( "explosion", function ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) local rx, ry, rz = getElementRotation ( thePlayer ) local origX, origY, origZ = getElementPosition ( thePlayer ) --why is this being defined? you're not modifying x, y, z in the code so this is going to remain identical to x, y, z defined earlier local mat = Matrix.create ( x, y, z+20, rx, ry, rz, origX - 30,origY+30,origZ) --I'm pretty sure this does not follow the syntax of Matrix.create which expects two vectors or 6 floats for position and rotation respectively. You've inputted 9 floats. local forward = ( Matrix.getForward ( mat ) * 4) local pos = ( Matrix.getPosition ( mat ) + forward ) --this would be the Vector3 for a position 4 units in front of mat, or in front of the player 20 units above on Z setTimer (createExplosion, 2000, 1,x+10, y, z, 11) --this creates an explostion 10 units to the north of the player (not relative to rotation) objs[thePlayer] = createObject(751, pos) --this creates an object 20 units above the player and 4 units in front local newZ = origZ +0 --this defined a variable that doesn't even get used moveObject( objs[thePlayer], 2000, origX, origY, origZ) --this moves the object to the player's position end ) Edited May 23, 2018 by MrTasty Link to comment
DiosSasuke Posted May 23, 2018 Author Share Posted May 23, 2018 what I wanted was to create an object that would appear above and when the object fell, the explosion would be activated and the problem is that the object appears above where I am, and I want it further away and where I am looking, and the explosion appears behind me and I want it to appear where I look the matrix did not work Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now