#well, where does this world come from.
1 messages · Page 1 of 1 (latest)
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.
? I thought the issue was, that the world is null
you can use TActorRange straightaway tho
seems like it broke it for some reason^^
also for AnimNotify, dont you want to get the character from the owner of the SkeletalMeshComponent?
Thank you. Good hint. But I guess the cruical thing here is that I would like to get this to be customisable via BP. As the idea is to use this as a base class
^
No. In this case im trying to fire a projectile from the enemy to the player (which should be the target).
in an anim notify?
you should not use GetActorOfClass
your Enemy should know who its attackig
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
but you wouldn't do the spawning in the animation notify
im running a function that spawns in in the anim notify
you simply tell the enemy now you can spawn projectile
so why do you need to use GetActorOfClass
because i want the projectile to follow the player character
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
I wanted to make this as a base clase. so i can reuse it for the player to target the enemy
if its a single player game, just use UGameplayStatics::GetPlayerCharacter but if this is multiplayer, then this is bad
not in the anim notify!
you can always use montage notify i suppose
PlayMontage -> AnimNotify -> GetOwner Char -> Spawn Projectile
your animnotify should have no projectile spawning logic
nor care
thats what it basically does.
so why hoyu using GetActorOfClass
if (Char) { Char->SpawnProjectile() };```
your SpawnProjectile will do the logic to spawn the projectile, etc
in the ABP
as i said i wanted it as a base class
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
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?
no
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