multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.4k stars 435 forks source link

Function "setVehicleComponentRotation/Position” does not change the position and rotation of the collision model #3820

Open T-MaxWiese-T opened 2 days ago

T-MaxWiese-T commented 2 days ago

Describe the bug

The function setVehicleComponentRotation and setVehicleComponentPosition does not change the position and rotation of the collision model. For example, changing the rotation of the fork of the forklift does not change the collision model rotation. This could lead to unwanted results.

Steps to reproduce

  1. Drive against a vehicle with the fork in a forklift.
  2. Execute this client code while sitting in a forklift:
    function fork()
    setVehicleComponentRotation(getPedOccupiedVehicle(localPlayer), "misc_a", 0, 0, 180)
    addCommandHandler("fork", fork)
  3. Hit the vehicle again with the fork. Although the fork rotation has changed, the rotation of the collision model has not changed.

Version

Client: v1.6-release-22763 Server: v1.6-release-22763

Additional context

I think the best solution would probably be to add an additional parameter to the setVehicleComponentRotation and setVehicleComponentPosition function that determines whether the vehicle component should have a collision or not so that the collision does not disturb if it is the case. With the setVehicleAdjustableProperty function, on the other hand, the collision model also shifts.

Relevant log output

No response

Security Policy

tut001 commented 2 days ago

setVehicleComponentPosition with collisions enabled could be useful if the collision spheres are actually configured with the correct collision component types (ie door, boot, special), but it doesn't really make sense to give setVehicleComponentRotation a collision on/off toggle if the sphere would just rotate around its pivot, unless it actually rotates around the vehicle pivot?

T-MaxWiese-T commented 1 day ago

setVehicleComponentPosition with collisions enabled could be useful if the collision spheres are actually configured with the correct collision component types (ie door, boot, special), but it doesn't really make sense to give setVehicleComponentRotation a collision on/off toggle if the sphere would just rotate around its pivot, unless it actually rotates around the vehicle pivot?

Whereby, for example, car doors and trunks do not have a collision, i.e. a differentiation into types would probably not make sense here. But the fire truck with ladder or the forklift with fork have a moving collision. You can see which models have a moving collision here: https://github.com/multitheftauto/mtasa-blue/blob/792d9aa6bbd6bdc451f3e78afacda5fdeb5df11b/Client/mods/deathmatch/logic/CClientVehicle.cpp#L1357 Regarding the rotation of the collision model not making a difference, yes I thought of that too, but it does make a difference. So in my code example with the forklift and the fork with the 180 degree rotation around the Z axis, the rotation of the collision model probably wouldn't make a difference, but if you rotated it 45 degrees for example it would make a difference. In the case of the fire truck with the ladder there, the rotation of the collision model definitely makes a difference. The GTA function CAutomobile::UpdateMovingCollision, which is responsible for moving the collision models, only accepts one parameter, namely the angle, but theoretically it would also be possible to completely change the position and rotation yourself.