primacy
(primacy)
September 13, 2016, 3:53am
1
Hi I am adding a projectile movement component dynamically and trying to shoot the arrow using the below code:
FName compname("Projectile");
ProjectileMovement = ConstructObject<UProjectileMovementComponent>(UProjectileMovementComponent::StaticClass(), this, compname);
if (ProjectileMovement)
{
ProjectileMovement->UpdatedComponent = CollisionComp;
ProjectileMovement->InitialSpeed = 3000.f;
ProjectileMovement->MaxSpeed = 3000.f;
ProjectileMovement->bRotationFollowsVelocity = true;
ProjectileMovement->bShouldBounce = false;
ProjectileMovement->RegisterComponent();
}
The arrow does not move and instead stays in place.
As a note, I do have the projectile parented to my vive controller which does have a sphere collision component. I am assuming that is the problem so how would I set my projectile to ignore it?
P.S. I am doing strictly C++ code.
You have to add a check on your onHit event in the projectile class:
OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) {
if ((OtherActor != NULL) && !OtherActor->IsA(<ClassToIgnore>::StaticClass()))
{
//Code
}...
Then this should not happen. If it still happens it is because of something else. Maybe another class. Try printing inside the //code part the name of the otheractor static class.
Gl. HTH.
primacy
(primacy)
September 13, 2016, 7:12pm
3
i actually did that and it still does not work. I am not even generating a OnHit Event. Instead all im getting is OnOverlapBegin
primacy
(primacy)
September 13, 2016, 7:25pm
4
I just tried taking off all my collision components from left controller, right controller, and projectile arrow.
Please show me the code for your on overlap begin and your shooting function.