riaaa
(Ria)
May 11, 2024, 8:14pm
1
okay. my main character takes damage when she hits my enemy… sometimes… can I somehow in the weapon BP be like
if (attacked actor == self)
{
do not damage
}
or
ActorsToIgnore.Add(OwningActor)
in the weapon BP like that it gets implemented to whoever is holding a weapon?
Ps: I do enable and disable box collision
Main Character ABP
MainCharacter AM
Main Character Mesh Collision
Weapon Box Collision
Weapon Mesh Collision
3dRaven
(3dRaven)
May 11, 2024, 9:30pm
2
Add your character to Ignore Actor when Moving for the weapon.
if you are using c++ then you can use owning actor. But be sure that the player character owns the weapon.
It won’t be set by default so call setOwner() on the weapon once you spawn the weapon and assign the character as the owner to be sure.
Then you can rely on passing in the owner.
riaaa
(Ria)
May 11, 2024, 9:49pm
3
well in the past I had tried something, because my character does not own the weapon.
in weapon.h, I did this
UPROPERTY()
TArray<AActor*> IgnoreActors;
and then in the character who collects the weapon when pressing the E key, I did this.
but it doesn’t work.
riaaa
(Ria)
May 11, 2024, 9:54pm
4
I think that it would have to go in my take damage function though right?
3dRaven
(3dRaven)
May 11, 2024, 9:59pm
5
You should use the ignore code for the weapon collision box
example where WeaponBox is a uboxcomponent collider for the weapon:
WeaponBox->IgnoreActorWhenMoving(MyCharacter,true);
And do this only once when equipping / unequipping not every time you attack.
riaaa
(Ria)
May 11, 2024, 10:26pm
6
so this is what I have so far, but it still doesnt work.
sometimes itll even hit both the enemy and me.
3dRaven
(3dRaven)
May 11, 2024, 10:37pm
7
Is this a single player or multiplayer game? If it’s MP then you need to set these parameters only on the server not the client.
Try printing out the actor ignore list for your weapon when it detects a hit (loop though the ignore list and see if your player character is present there). Perhaps it’s being reset somewhere else in the game?
riaaa
(Ria)
May 11, 2024, 10:44pm
8
okay I didn’t think about it clashing together… i do have this in here.
3dRaven
(3dRaven)
May 11, 2024, 10:46pm
9
It would probably best it you unify the ignore list for both traces and collisions in this case.
riaaa
(Ria)
May 11, 2024, 10:53pm
10
YES!! it worked!! I passed in get owner instead of actor!! thank you!! again!! :)!!
system
(system)
Closed
June 10, 2024, 10:53pm
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.