FVector Rotation Troubles

I’m very confused as of why this script works because if I’m reversing the vector of a rotation isn’t that flipping it? The goal was to make the particle rotate on spawn based off of the rotation of the vector.Rotation() and the vector comes from a Rotation Vector which has the rotation of the camera i believe so I don’t get why this doesn’t act weirdly.

FVector Location;
		FRotator Rotation;

		OwnerController->GetPlayerViewPoint(Location, Rotation);

		FHitResult HitResult;
		FVector End = Location + Rotation.Vector() * MaxRange;


		bool HasHit = GetWorld()->LineTraceSingleByChannel(
			HitResult,
			Location,
			End,
			ECC_GameTraceChannel1);

		if (HasHit)
		{
			FVector ShotDirection = -Rotation.Vector();
			UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ImpactParticle, HitResult.Location, ShotDirection.Rotation());

			if(HitResult.GetActor())
			{
				FPointDamageEvent DamageEvent(Damage, HitResult, ShotDirection, nullptr);
				HitResult.GetActor()->TakeDamage(Damage, DamageEvent, OwnerController, this);
			}
		}

A negated unit vector is a vector going in the opposite direction.

This is for the impact particle. If you were to shoot at a wall you would want the particle effect to be shown towards you, which is in the exact opposite direction you fired it.

For illustrative purposes | is the wall and o is the character with arrows showing the direction of the particle and character respectively.

|->    <-o

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms