So far nobody on any Discord channels has had any answers to this issue, and it’s been really unproductive trying to Google something like this, so I’m just hoping someone might recognize these symptoms and have some advice here.
I’ve created a grenade actor that will be spawned via GetWorld()->SpawnActor. The actor has a ProjectileMovementComponent and a StaticMesh. The projectile movement component is set to use an initial speed/max speed of 1000.0, and bShouldBounce is set to true. Other than that, all settings are default.
The behavior I’ve observed is:
- The actor spawns into the world and shows up in the actor list. However, instead of using the given location, it appears to travel off in some random X/Y/Z direction at a really high rate.
- Along with this, it is invisible. I can never see the static mesh leave from any direction, and when selecting it from the actor list and focusing it, there is never anything there.
- When pausing the editor, the actor continues to travel at the random rate/direction.
- I have set a lifetime on the actor of 5 seconds, it seems to totally ignore this.
My code for the spawning process is as follows:
void ASurvivalCharacter::SpawnThrowable()
{ if (UThrowableItem* throwable = GetThrowable()) // returns the reference to the throwable item from the inventory
{
[INDENT=2]if (throwable->throwableClass) // check that the weapon class is valid
{[/INDENT]
[INDENT=3]FActorSpawnParameters spawnParams;
spawnParams.Owner = spawnParams.Instigator = this;
spawnParams.bNoFail = true;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
FVector eyesLocation;
FRotator eyesRotation;
// load the controller location into the two vectors
GetController()->GetPlayerViewPoint(eyesLocation, eyesRotation);
// spawn grenade slightly in front of controller location so it won't collide with the player
eyesLocation = (eyesRotation.Vector() * 20.0f) + eyesLocation;
if (GetWorld()->SpawnActor<AThrowableWeapon>(throwable->throwableClass, FTransform(eyesRotation, eyesLocation), spawnParams))
{[/INDENT]
[INDENT=4]MulticastPlayThrowableFX_Implementation(throwable->throwAnimation); // play the throw animation[/INDENT]
[INDENT=3]}[/INDENT]
[INDENT=2]}[/INDENT]
}
}
I’ve uploaded a short video of the actor list immediately after the code executes: https://i.imgur.com/lPRuIpw.mp4
I haven’t used the projectile movement component much, so hopefully this is just some dumb mistake I’m making with the spawn params or the setup of the movement. Any advice would be greatly appreciated.