mafioz Posted June 28, 2022 Share Posted June 28, 2022 Hello. I have a question. How can you make vertical recoil in MTA? This is done in this video, while shooting, the scope goes up: Link to comment
AngelAlpha Posted June 28, 2022 Share Posted June 28, 2022 4 minutes ago, shishani said: Hello. I have a question. How can you make vertical recoil in MTA? This is done in this video, while shooting, the scope goes up: Vertical recoil for shotgun? Link to comment
mafioz Posted June 28, 2022 Author Share Posted June 28, 2022 1 minute ago, AngelAlpha said: Вертикальная отдача для дробовика? No. For any weapon Link to comment
AngelAlpha Posted June 28, 2022 Share Posted June 28, 2022 (edited) 4 minutes ago, shishani said: No. For any weapon try this code (client) local coef = 0.5 addEventHandler ("onClientWeaponFire", root, function() if source ~= localPlayer then return end local x, y, z, lx, ly, lz = getCameraMatrix () setCameraTarget (lx, ly, lz + coef) end) Edited June 28, 2022 by AngelAlpha Link to comment
mafioz Posted June 28, 2022 Author Share Posted June 28, 2022 6 minutes ago, AngelAlpha said: try this function local coef = 0.5 addEventHandler ("onClientWeaponFire", root, function() if source ~= localPlayer then return end local x, y, z, lx, ly, lz = getCameraMatrix () setCameraTarget (lx, ly, lz + coef) end) Does not work. The player's camera rotates approximately 180 degrees. Link to comment
mafioz Posted June 28, 2022 Author Share Posted June 28, 2022 I'm waiting for your help Link to comment
AngelAlpha Posted June 28, 2022 Share Posted June 28, 2022 2 minutes ago, shishani said: I'm waiting for your help I don't know) Link to comment
Spakye Posted June 29, 2022 Share Posted June 29, 2022 Hello, try to replace setCameraTarget(...) with setCameraMatrix( x, y, z, lx, ly, lz + coef ) If it doesnt work you can also try something with get and setCursorPosition Link to comment
AngelAlpha Posted June 29, 2022 Share Posted June 29, 2022 7 hours ago, Spakye said: Hello, try to replace setCameraTarget(...) with setCameraMatrix( x, y, z, lx, ly, lz + coef ) If it doesnt work you can also try something with get and setCursorPosition setCursorPosition work if cursor is showing Link to comment
mafioz Posted June 29, 2022 Author Share Posted June 29, 2022 (edited) 13 hours ago, Spakye said: Здравствуйте, попробуйте заменить setCameraTarget(...) на setCameraMatrix(x, y, z, lx, ly, lz + coef) Если это не сработает, вы также можете попробовать что-нибудь с помощью get и setCursorPosition. Hello. Thanks for your reply. When using setCameraMatrix I won't be able to rotate the camera. The only function to do this is setCameraTarget, now we need to get the correct camera direction to move it up a bit. Edited June 29, 2022 by shishani Link to comment
Spakye Posted June 30, 2022 Share Posted June 30, 2022 (edited) setCameraTarget doesnt allow you to move it up sadly. Did you see this topic? Edited June 30, 2022 by Spakye Link to comment
mafioz Posted June 30, 2022 Author Share Posted June 30, 2022 4 часа назад, Скай сказал: setCameraTarget не позволяет вам, к сожалению, переместить его вверх. Вы видели эту тему? I want vertical recoil, not horizontal. Link to comment
Spakye Posted June 30, 2022 Share Posted June 30, 2022 (edited) local coef = 0.01 function test(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement, startX, startY, startZ) if source ~= localPlayer then return end setCameraTarget(hitX, hitY, hitZ + coef) local rot = 360- getPedCameraRotation(localPlayer) setPedCameraRotation ( localPlayer, rot + 0.5 ) end addEventHandler("onClientPlayerWeaponFire", root, test) Try this, its not neat, there is some math to do but its a start Edited June 30, 2022 by Spakye 1 Link to comment
AngelAlpha Posted June 30, 2022 Share Posted June 30, 2022 2 hours ago, Spakye said: local coef = 0.01 function test(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement, startX, startY, startZ) if source ~= localPlayer then return end setCameraTarget(hitX, hitY, hitZ + coef) local rot = 360- getPedCameraRotation(localPlayer) setPedCameraRotation ( localPlayer, rot + 0.5 ) end addEventHandler("onClientPlayerWeaponFire", root, test) Try this, its not neat, there is some math to do but its a start setPedCameraRotation rotate camera relative to the Z axis Link to comment
Spakye Posted July 1, 2022 Share Posted July 1, 2022 (edited) Mate just start the game and try this it does what you want. It does need more work to make it look nice though the cam rotation is just here to fix the camera going a little bit to the right because im lazy to do some math to find precise positions. Edited July 1, 2022 by Spakye Link to comment
mafioz Posted July 1, 2022 Author Share Posted July 1, 2022 7 hours ago, Spakye said: Приятель, просто запусти игру и попробуй, она делает то, что ты хочешь. Но нужно больше работать, чтобы это выглядело красиво вращение кулачка просто здесь, чтобы зафиксировать движение камеры немного вправо, потому что мне лень заниматься математикой, чтобы найти точные положения. This function rotates the camera to the right or left, so the function is not suitable. I need the camera to be pointing up for vertical recoil. Link to comment
mafioz Posted July 1, 2022 Author Share Posted July 1, 2022 I'm waiting for your help Link to comment
Spakye Posted July 1, 2022 Share Posted July 1, 2022 As i said, it does what you want. Link to comment
mafioz Posted July 6, 2022 Author Share Posted July 6, 2022 On 7/1/2022 at 6:33 PM, Spakye said: As i said, it does what you want. Yes, I didn't notice the setCameraTarget function in your code, it really works. But I would like the sight to rise up smoothly, and not abruptly. Thank you 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