Leaderboard
Popular Content
Showing content with the highest reputation on 19/10/19 in all areas
-
For long time i considered to do something with physics in mta. For now doing even simplest things such falling box, tree on flat area looks cartoonish. In my history of i saw few attempts of doing simple physics, mostly it was in closed area without bigger interactions with poor performance due you just can't calculate collision in other way than processLineOfSight, isLineOfSightClear or read directly .col file as Tederis did. I started with something to render things, thats how FBX https://github.com/multitheftauto/mtasa-blue/pull/1093 to bypass default rendering to handle future i'll introduce in future. That's how bullet physics project born, first idea how to use react physics, works simillar but is lighter and general smaller project but 0x416c69 suggested to use bullet. I'll use this topic also to prepare long list of features it contains for future copy paste to PR and wiki page The main assumption is to allow for create multiple world with completly independed simulations, get and set detailed information about current step of simulation, fully control how everything is simulated, quality of collision tests, speed and a lot more. i'm trying keep amount of functions low, because if that most stuff is packed into one function. Syntax and name of some function might change in future or along suggestions. Not all properties supports every physics element, some are only get, other set only, however most of them are set/get Current stage: I already implemented function such a: physics physicsCreateWorld() - responsible for creating new world for simulations, return element which will use later. physics-rigidbody physicsCreateRigidBody( shape-type, mixed arguments ) - creates rigid body which is use to simulation bahaviour of non-static shapes, collisions ( currently only few models in mta can do this in simple way ). physics-rigidbody physicsCreateRigidBodyFromModel( model ) - used to create rigid body directly from collision data taken from gta model. physics-static-collision physicsCreateStaticCollision( shape-type, mixed arguments ) - creates static collision which will not move at all ( it is still possible to move it by Lua script ) physics-shape physicsAddShape( shape-type, mixed arguments ) - if you create compound shape, this function let you add more shapes into static collision or rigid body bool physicsSetProperties( any physics element, physics-property, mixed arguments ) - main function to control physics, rigid bodies, static collisions, shapes. Works in simillar way as handling functions. mixed physicsGetProperties( any physics element, physics-property ) - same as above, but getting properties bool physicsDrawDebug( physics ) - use to visualization of world, must be used in render function bool physicsSetDebugMode( physics-debug-mode, enabled ) - use to turn off/on debugging features bool physicsBuildCollisionFromGTA( physics ) - used to create static collisions in specified world from original collisions, doesn't create whole world instantly, require to move player around world to load collision data. physics-constraint physicsCreateConstraint( physics, physics-rigid-body, physics-rigid-body, constraint-type, mixed arguments ) - use to connecting two or more rigid bodies into one entity bool physicsApplyForce( physics-rigid-body, vector from, vector to ) - pushing rigid body in particular point you choosed. bool physicsApplyCentralForce( physics-rigid-body, vector direction ) - apply force from central position of rigid, it's more like "accelereate", should be used more than once at the some period of time bool physicsApplyCentralImpulse( physics-rigid-body, vector direction ) - setting position from center of rigid bool physicsApplyDamping( physics-rigid-body, float force ) - i'm not sure, but it should slow down velocity and rotation of model by specified amount of units physicsApplyImpulse( physics-rigid-body, vector direction ) - i'm not sure how it works physicsApplyTorque( physics-rigid-body, vector rotation ) - same as physicsApplyCentralForce but for rotation physicsApplyTorqueImpulse( physics-rigid-body, vector rotation ) - setting rotation speed physics-properties: "mass", "position" ,"rotation", "sleepingthresholds", "restitution", "scale" "debugcolor", "filtermask", "filtergroup", "stiffness" `sleepingthresholds` means how slow rigid must move/rotate to sleep, it makes stops moving at all but still can be pushed by other rigids `restitution` bounciness, between 0-1 but accept any value above `stiffness` - for fixed constraint `filtermask` i still figuring out how it work, but should let you use 32 bit mask to set which rigid with which should collide Bullet documentation: https://github.com/bulletphysics/bullet3/blob/master/docs/Bullet_User_Manual.pdf page 13 contains useful information when which shape should be used physics-constraints: "pointtopoint", "hidge", "fixed", "slider" Physics-shapes: "box", "sphere", "capsule", "cone", "cylinder", "heightfieldterrain", "compound", "trianglemesh", "convexhull" `compound` is used for constructing rigid made of various shapes Plans for future: "heightfieldterrain" shape type accept black-white texture for faster creation Support for cloths, soft bodies Media: Videos are availiable at my youtube channel https://www.youtube.com/channel/UC95MpsQ1JppDNpMvl_7c1rg screenshots and gifs of current progress: Documentation i use: https://pybullet.org/Bullet/BulletFull I'm waiting for your suggestions Topic not finishedd2 points
-
2 points
-
Não é necessário usar isElementWithinMarker se você estiver usando onClientMarkerHit, pois quando um elemento colide em um marker, obviamente ele já vai estar dentro do marker. É o mesmo que verificar se o jogador está dentro do veículo logo após o evento onVehicleEnter.1 point
-
Já falei da outra vez e vou repetir: Não use source como parâmetro de função. local markerInput = createMarker (1555.1072998047, -1675.6097412109, 16.69611, "arrow", 1, 255, 255, 0, 50) local markerOutput = createMarker (1555.1072998047, -1675.6097412109, 16.69611, "arrow", 1, 255, 255, 0, 50) function inputPD (hitElement) if (hitElement and getElementType (hitElement) == "player") then if (getPedOccupiedVehicle (hitElement)) then outputChatBox ("| SS | Você não pode entrar com veículo na DP.", hitElement, 255, 255, 255) else setElementInterior (hitElement, 6) setElementPosition (hitElement, 246.6756439209, 65.71768951416, 1003.640625, true) outputChatBox ("| SS | Você entrou na #ff0000Delegacia de Polícia#ffffff.", hitElement, 255, 255, 255, true) end end end addEventHandler ("onMarkerHit", markerInput, inputPD) Sobre o problema da mensagem aparecer e o jogador teleportar mesmo assim, é porque sua função estava sendo executada 2x, uma pro carro que colidiu no marker e outra pro jogador que colidiu no marker. Para corrigir esse problema, basta adicionar uma condição para que a função só funcione se o elemento que colidiu for um player.1 point
-
O source aparece na Wiki do evento. Só saber ler. No caso do onPlayerJoin: The source of this event is the player who joined. E o motivo do seu script não estar funcionando antes é pq o evento onPlayerJoin não tem parâmetros de função. Logo, quando vc declara source como parâmetro de função, ele fica nil. Você não deve declarar source como parâmetro de função. Isto é um erro.1 point
-
If playerZ < getWaterLevel(playerX, playerY, playerZ)1 point
-
I've not been on for a while but much respect to you as always, SugarD-x. Vice City will never die..1 point
-
Você vai precisar de uma noção básica de programação para entender a sintaxe. setElementData( element, data, valor ) element: elemento do MTA data: uma identificação única da elementData no formato string valor: um valor válido (https://wiki.multitheftauto.com/wiki/Element_data) Exemplo: setElementData( getPlayerFromName("ODutii"), "fakeMoney", 9999999 )1 point
-
Parâmetros da função addCommandHandler (server-side): player playerSource, string commandName [, string arg1, string arg2, ... ] Ou seja, faz todo sentido acontecer.1 point
-
function byType(vehicle) local var = getElementType(vehicle) outputChatBox("Bom jogo.", source) end addCommandHandler("type", byTipe) Tenta isso1 point
-
This information might also be useful for you: local x, y, z = 0, 0, 10 local rx, ry, rz = 0, 0, 0 -- test rx, ry, rz = (rx + math.random(3)) % 360, (ry + math.random(3)) % 360, (rz + math.random(3)) % 360 -- local m = createMatrix(x, y, z, rx, ry, rz ) local startX, startY, startZ = getPositionFromMatrixOffset(m, 0, 1, 0) local endX, endY, endZ = getPositionFromMatrixOffset(m, 0, -1, 0) local faceTowardX, faceTowardY, faceTowardZ = getPositionFromMatrixOffset(m, 1, 0, 0) (functions are on that topic)1 point
-
This might help you: (based on these examples) function createMatrix(x, y, z, rx, ry, rz) rx, ry, rz = math.rad(rx), math.rad(ry), math.rad(rz) local matrix = {} matrix[1] = {} matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry) matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry) matrix[1][3] = -math.cos(rx)*math.sin(ry) matrix[1][4] = 1 matrix[2] = {} matrix[2][1] = -math.cos(rx)*math.sin(rz) matrix[2][2] = math.cos(rz)*math.cos(rx) matrix[2][3] = math.sin(rx) matrix[2][4] = 1 matrix[3] = {} matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx) matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx) matrix[3][3] = math.cos(rx)*math.cos(ry) matrix[3][4] = 1 matrix[4] = {} matrix[4][1], matrix[4][2], matrix[4][3] = x, y, z matrix[4][4] = 1 return matrix end function getPositionFromMatrixOffset(m, offX, offY, offZ) local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end With this you can calculate from every orientation the matrix and offset positions. Feel free to apply a different rotation value, so that the offset is also turning. Optional method: (but might not be 100% accurate) Between 2 positions in front of you can rotate the camera, see: https://wiki.multitheftauto.com/wiki/InterpolateBetween I hope this will make you see the light, it did for me when doing complex 3D calculations.1 point
-
O voice do MTA não trabalha localmente se não estou errado. Use este voice: https://community.multitheftauto.com/index.php?p=resources&s=details&id=142811 point
-
1 point