#well, where does this world come from.

1 messages · Page 1 of 1 (latest)

fallow wagon
#

thanks. I found out that this (commented part) causes the failure:

//Target = UGameplayStatics::GetActorOfClass(World, TargetClass->StaticClass());
Target = UGameplayStatics::GetActorOfClass(World, AKerapacCharacter::StaticClass());

At the moment I'm constructing theTargetClass as a UClass*. As that does not work properly, I guess thats the wrong way.

loud zephyr
#

? I thought the issue was, that the world is null

robust spruce
#

you can use TActorRange straightaway tho

fallow wagon
robust spruce
#

also for AnimNotify, dont you want to get the character from the owner of the SkeletalMeshComponent?

fallow wagon
regal latch
#

^

fallow wagon
regal latch
#

in an anim notify?

#

you should not use GetActorOfClass

#

your Enemy should know who its attackig

fallow wagon
#

how is the flow then supposed to be (currently I'm just blatanly setting this up without any behaviortree etc. and I'd obviously like to spawn the projectile at a specfic point in time during the animation runtime.

#

my flow right now is determine_attack_type -> play_attack_animation -> spawn projectile as separate actor as reaction to anim_notify

regal latch
#

but you wouldn't do the spawning in the animation notify

fallow wagon
#

im running a function that spawns in in the anim notify

regal latch
#

you simply tell the enemy now you can spawn projectile

#

so why do you need to use GetActorOfClass

fallow wagon
#

because i want the projectile to follow the player character

regal latch
#

your animnotify should NOT spawn the projectile

#

or care for the projectile

#

it should tell the ai, go spawn the projectile

#

and you should never be using Getactorofclass etc to find the player

#

the AI should know who its targeting

fallow wagon
regal latch
#

if its a single player game, just use UGameplayStatics::GetPlayerCharacter but if this is multiplayer, then this is bad

#

not in the anim notify!

robust spruce
#

you can always use montage notify i suppose

regal latch
#

PlayMontage -> AnimNotify -> GetOwner Char -> Spawn Projectile

#

your animnotify should have no projectile spawning logic

#

nor care

fallow wagon
regal latch
#

so why hoyu using GetActorOfClass

#
  if (Char) { Char->SpawnProjectile() };```
#

your SpawnProjectile will do the logic to spawn the projectile, etc

fallow wagon
regal latch
#

ok

#

i am super confused now

#

why are you using Target = UGameplayStatics::GetActorOfClass(World, AKerapacCharacter::StaticClass());
to find the player

#

if its single player just use UGameplayStatics::GetPlayerCharacter

fallow wagon
#

I want to use thsi class that uses the function as a base class. so that i can reuse it for the player to find the enemy as well

#

therefore i use getactor of class

#

since there will be one player and one enemy

#

is that more clear now?

regal latch
#

no

fallow wagon
#

Ok. So the current situation is, that I have an enemy, which has an ABP attached to it and the AnimNotify as above. I've setup a blueprint of the projectile in question which gets spawned by the function in the graph above. In this case, the projectile should chase the player (therefore im trying to get the player via its class, as it is the only instance). Lateron, I would also like to reuse the projectile class such that the player can fire the projectile chasing the enemy. therefore I would not want to use UGameplayStatics::GetPlayerCharacter

#

the line Target = UGameplayStatics::GetActorOfClass(World, TargetClass->StaticClass()); is in the BeginPlay of the projectile itself. And in this instance the target would be the player, as the projectile should chase its target.

#

in other cases it might be spawned from the player to chase the enemy

regal latch
#

dont use ->StaticClass

#

just TargetClass