#Is owner value changes after a certain distance?

9 messages · Page 1 of 1 (latest)

spark current
#

Hello friends

@livid hollow and I need some help with collision detection between players and projectiles.
In summary, we can shoot properly and hit opponent players when they are close, but when they are abit farther away, the collision between the opponent and the projectile is no longer registered.

for the collision detection, we first check if the player that was hit is the owner of the projectile. If the player is indeed the owner, then we return.
If they are not the owner, this means they are an opponent player, then we deal damage, play the impact FX, and destroy the projectile(return to pool).

We tried to debug this by checking the object ID of the player that got hit against the network object id of the owner that spawned the projectile (playerthatgothit.owner.networkobject.objectid).

When the casting player and the target player are close, the values would be different, and therefore the projectile impact would work.

However, past a certain distance, the values would no longer be different.
The network object ID of the player getting hit would be the same network object ID as the player that spawned it, eventhough that should not be the case as they are different players.

This is also the case for AI objects. they can be impacted when close, but not when far.

Are we missing something?
Hopefully its something small 😭 😭 😭
I've attached a video of how this looks like in our game.

Thank you all for reading and for your help (:

merry wraith
livid hollow
#

I get the same behaviour even when using that value

merry wraith
#

How are you storing the value on the projectile?

livid hollow
#
 if (other.GetComponent<WizardInstance>())
  {
      #region Checks if Player isnt hitting themselves
      
      WizardInstance victim = other.GetComponent<WizardInstance>();
      if (victim.NetworkObject.OwnerId == base.NetworkObject.OwnerId  || !victim.IsCharacterVisible() || victim.Health() <= 0)
                        return;
                    #endregion

                    WizardProjectileDamage(victim);
                }

So the value for the victim and owner initially doesnt match until the collision happens. I checked this value and others in the update loop and it stayed consistent if it wasnt colliding with anything, but when i debug this and try the collision, the value changes. It doesnt make sense. And we aren't transfering any ownership or anything like that

#

using ```cs
if(victim.Owner == base.Owner)

merry wraith
#

Hmm, what OwnerId is it printing when this stops working?

livid hollow
# merry wraith Hmm, what OwnerId is it printing when this stops working?

So strange conclusion... The direction wasnt normalized when passed in so the projectile was actually going forward at a diagonal angle. I managed to patch that and once the prjectile was amoving straight it works fine .
We're obviously happy about this fix but it still doesnt explain what was happening with the values whenever the projectile would go in the previous direction 🤷🏽

livid hollow