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

Split grenade collision from weapon collision

Open Merlin opened this issue 3 years ago • 10 comments

This most likely fixes #1123 Atleast I couldn't identify any other change that happens on first grenade throw.

Currently on the first grenade throw we add a colsphere into the colmodel of the grenade. But all weapon models have the same colmodel set. This PR splits grenades into their own colmodel and also adds the colsphere on game start.

I tested it and it splits the collision. But I can't say if this completely fixes #1123. This is however still an useful change because multiple people ran into the issue that weapons/projectiles have collision where they should not have any.

Merlin avatar Aug 18 '22 21:08 Merlin

This most likely fixes #1123

Needs to be confirmed.

This is however still an useful change because multiple people ran into the issue that weapons/projectiles have collision where they should not have any.

Why not? Personally I use the fact that weapon objects have collisions in my gamemode. You can disable these via setElementCollisionsEnabled, which apparently doesn't work on weapon elements but it's different issue (#1365).

Weapon objects doesn't have any collisions after this change?

lopezloo avatar Aug 18 '22 22:08 lopezloo

Weapon objects doesn't have any collisions after this change?

Weapons by default do not have any collisions. Only after the first grenade throw they have collision. I think it should be consistent and not change mid game when someone throws a grenade.

Merlin avatar Aug 18 '22 23:08 Merlin

I think it should be consistent and not change mid game when someone throws a grenade.

I agree. We could initialize that collision then. In my gamemodes I always used to create projectile at the resource start to fix this. I just don't get why do you want to seperate it from other weapon models. I think it would be nice for weapon models to have collisions.

lopezloo avatar Aug 19 '22 04:08 lopezloo

I think it would be nice for weapon models to have collisions.

Wouldn't more collisions cause more overhead? If there aren't any actual benefits from collisions there shouldn't be any. We should benchmark any difference since depending on the server there may be thousands of weapons in use at a time.

patrikjuvonen avatar Aug 19 '22 06:08 patrikjuvonen

I think it would be nice for weapon models to have collisions.

Wouldn't more collisions cause more overhead? If there aren't any actual benefits from collisions there shouldn't be any. We should benchmark any difference since depending on the server there may be thousands of weapons in use at a time.

I don't think it affects weapons carried by players.

lopezloo avatar Aug 19 '22 07:08 lopezloo

Player held weapon don't have collisions, so why should custom weapons have them? In any case, you can always attach an invisible object with a collision to a custom weapon if you need them, it'd be still a less hacky solution than relying on current blatantly erroneous behavior.

1iminal avatar Aug 23 '22 02:08 1iminal

Player held weapons/custom created weapons shouldn't have collisions - at least not by default. If it would be added, it should be toggleable via function, and not being enforced.

sacr1ficez avatar Aug 23 '22 10:08 sacr1ficez

Player held weapon don't have collisions, so why should custom weapons have them?

But that change affect objects too.

We could fix #1365 and then make custom created weapons collisionless by default.

So, in summary, my proposal is:

  • initialize that collision
  • add custom created weapons support to setElementCollisionsEnabled (fix #1365)
  • make custom created weapons collisionless by default

lopezloo avatar Aug 23 '22 11:08 lopezloo

I agree that setElementCollisionEnabled should work for custom weapons. But I don't think making custom weapons collisionless by default is the right choice. When I replace the collision of a weapon model I expect the collision be there by default for custom weapons.

If anyone needs the grenade collision on weapon objects they can always just add a collision to that weapon model. It's just a col sphere with center = {0.0, 0.0, 0.0} and radius = 0.1875

Merlin avatar Sep 11 '22 16:09 Merlin

Thinking about it now, making custom created weapons collisionless by default would break backward compatibility because it's actually possible to create weapon with model different than weapon model (it's possible to use setElementModel on weapon elements). Also it's possible to replace weapon model as you said.

I don't like the idea of making weapon models collisionless though. Maybe we could initialize small box collison for weapon models. But that would kinda break backward compatibility too.

lopezloo avatar Sep 18 '22 06:09 lopezloo