void UTankMovementComponent::RequestDirectMove(const FVector& MoveVelocity, bool bForceMaxSpeed) { auto TankForward = GetOwner()->GetActorForwardVector().GetSafeNormal(); auto AIForwardIntention = MoveVelocity.GetSafeNormal(); auto ForwardThrow = FVector::DotProduct(TankForward, AIForwardIntention); auto RightThrow = FVector::CrossProduct(AIForwardIntention, TankForward); IntendMoveForward(ForwardThrow); IntendTurnRight(RightThrow.GetSafeNormal().Z); }
void UTankMovementComponent::RequestDirectMove(const FVector & MoveVelocity, bool bForceMaxSpeed) { // No need to call super as we replacing Parent method FVector TankForward = GetOwner()->GetActorForwardVector().GetSafeNormal(); FVector AIForwardIntention = MoveVelocity.GetSafeNormal(); float ForwardThrow = FVector::DotProduct(TankForward, AIForwardIntention); IntendMoveForward(ForwardThrow); float RightThrow = FVector::CrossProduct(TankForward, AIForwardIntention).Z; IntendTurnRight(RightThrow); }
void UTankMovementComponent::RequestDirectMove(const FVector& MoveVelocity, bool bForceMaxSpeed) { //No reason to call super because we are replacing the functionality auto TankForward = GetOwner()->GetActorForwardVector().GetSafeNormal();//Gets the x vector of the tanks auto AIForwardIntention = MoveVelocity.GetSafeNormal();//safe normal, gets you a normal vertor of of this move velocity with out changing it auto ForwardThrow = FVector::DotProduct(TankForward, AIForwardIntention); // auto RightThrow = FVector::CrossProduct(TankForward, AIForwardIntention).Z;// The sine Function //We ge the z component to get a float IntendMoveForward(ForwardThrow); IntendTurnRight(RightThrow); }
void UTankMovementComponent::RequestDirectMove(const FVector & MoveVelocity, bool bForceMaxSpeed) { auto tankForward = GetOwner()->GetActorForwardVector().GetSafeNormal(); auto aiForwardIntention = MoveVelocity.GetSafeNormal(); auto cosThrow = FVector::DotProduct(tankForward, aiForwardIntention); auto sinThrow = FVector::CrossProduct(tankForward, aiForwardIntention).Z; IntendMoveForward(cosThrow); IntendTurnRight(sinThrow); //UE_LOG(LogTemp, Warning, TEXT("cosThrow is %f"), cosThrow); //UE_LOG(LogTemp, Warning, TEXT("sinThrow is %f"), sinThrow); }
void UTankMovementComponent::RequestDirectMove(const FVector& MoveVelocity, bool bForceMaxSpeed) { // No need to call super - we are replacing functionality auto TankForward = GetOwner()->GetActorForwardVector().GetSafeNormal(); // Current Heading - unit vector direction relative to the global auto AIForwardIntention = MoveVelocity.GetSafeNormal(); // Direction we WANT to be heading float ForwardVelocity = FVector::DotProduct(TankForward, AIForwardIntention); IntendMoveForward(ForwardVelocity); float RotateVelocity = FVector::CrossProduct(TankForward, AIForwardIntention).Z; IntendTurnRight(RotateVelocity); // auto TankName = GetOwner()->GetName(); // UE_LOG(LogTemp, Warning, TEXT("%s Rotating to: %f"), *TankName, RotateVelocity); }
void UTankMovementComponent::RequestDirectMove(const FVector & MoveVelocity, bool bForceMaxSpeed) { //No need to call super as we're replacing the functionality //Current Forward auto TankForward = GetOwner()->GetActorForwardVector().GetSafeNormal(); //Direction that tank would like to be heading auto AIForwardIntention = MoveVelocity.GetSafeNormal(); //Use vector dot product to determine degree of move forward or back. 0 when perp to tank. auto ForwardThrow = FVector::DotProduct(TankForward, AIForwardIntention); IntendMoveForward(ForwardThrow); auto RightThrow = FVector::CrossProduct( TankForward, AIForwardIntention).Z; IntendTurnRight(RightThrow); //UE_LOG(LogTemp, Warning, TEXT("%s Veloctoring to %s"), *TankName, *MoveVelocityString); }