mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Ability to enable/disable custom weapons collisions

Open Brian9221 opened this issue 5 years ago • 9 comments

Describe the bug Creating a custom weapon with createWeapon doesn't let you to disable its collisions with setElementCollisionsEnabled or setElementCollidableWith.

To reproduce crun w = createWeapon("uzi", getElementPosition(localPlayer)) crun setElementCollisionsEnabled(w, false) crun setElementCollidableWith(w, localPlayer, false)

both collisions functions return false since they don't support weapon elements

crun setWeaponFlags(w, "disable_model", true)

doesn't remove collisions but only the model

Expected behaviour At least one of the 3 functions above should be useful to disable other elements from colliding with custom made weapons

Version

Brian9221 avatar Apr 09 '20 22:04 Brian9221

Why is this flagged as 'bug', when its clearly a feature request?

Pirulax avatar Jun 08 '20 18:06 Pirulax

Okay, so I've tried it, but they dont seem to have collisions by default.. Please provide me a custom model if you have used one on it. It makes sense why setElementCollisionsEnabled didnt support it.

Pirulax avatar Jun 08 '20 18:06 Pirulax

A weapon is not an element. It should not work with any setElement* functions unless we change weapons to be elements.

Therefore (if the original issue is even relevant / replicable), weapons should have their own functions to support this (following the setWeapon* / getWeapon* naming scheme)

Lpsd avatar Jun 09 '20 14:06 Lpsd

Weapon extends object https://github.com/multitheftauto/mtasa-blue/blob/e11685cab4beb7958ab202261f9c9d9b4ce71e58/Client/mods/deathmatch/logic/CClientWeapon.h

Which extends CClientStreamElement which extends CClientEntity (element) https://github.com/multitheftauto/mtasa-blue/blob/ff6715d7354d54b821672aa83fecf82457299575/Client/mods/deathmatch/logic/CClientStreamElement.h

So I think weapons are elements

qaisjp avatar Jun 09 '20 15:06 qaisjp

You are correct, I confused normal weapons with custom weapons created using createWeapon

Lpsd avatar Jun 09 '20 15:06 Lpsd

They're elements, and I did add setCollisionsEnabled with 2 lines of code, but after testing it I realized weapons have no collisions by default. Thats why I said please provide custom models, so I can see whats happening. Also, I think if u just dont replace the COL, it'll work just fine.

Pirulax avatar Jun 09 '20 21:06 Pirulax

Creating a projectile enables collisions on custom weapon elements, I've made a simple resource to reproduce this bug. This resource assumes the player is already spawned before it's started. On resource start, a custom weapon element is created and attached to the localPlayer (it doesn't really matter if its attached or not, but this helps to see the effect right away). Shooting any weapon will create and launch a grenade type projectile towards world position localPlayer was aiming at. At this very moment the custom weapon element suddenly obtains collision and begins to collide with camera, get in the way of player's movements, etc. This effect persists between sessions (after restarting the resource all custom weapons will be created with collision already enabled), and even custom weapons created on other servers will also have collisions, so the only way to get rid of collisions is to restart the game. issue1365.zip

1iminal avatar Aug 18 '22 16:08 1iminal

@Liminalia First thrown/spawned grenade will add collision to it. Since all weapons use the same colmodel they all have that collision. Take a look at: https://github.com/multitheftauto/mtasa-blue/issues/1123#issuecomment-1216080011 I will later work on the PR to split grenade collision from all other weapon collision.

Merlin avatar Aug 18 '22 17:08 Merlin

Good to hear, best of luck to you

1iminal avatar Aug 18 '22 17:08 1iminal