void AsixDOFPawn::Tick(float DeltaSeconds) { bool ret = OurTick(DeltaSeconds); if(ret) { //printf("running %f\n",DeltaSeconds); const FVector LocalMove = FVector(m_vx*10, m_vy*10, -m_vz*10);//(CurrentForwardSpeed * DeltaSeconds, 0.f, 0.f); //FVector curMove = GetVelocity();//(CurrentForwardSpeed * DeltaSeconds, 0.f, 0.f); FVector curMove = ReplicatedMovement.LinearVelocity; printf("------> %f %f %f \n",curMove.X, curMove.Y, curMove.Z ); // Move plan forwards (with sweep so we stop when we collide with things) AddActorLocalOffset(LocalMove, true); // Calculate change in rotation this frame FRotator DeltaRotation(0,0,0); //printf("Delta -> %f %f %f \n",m_Deltaroll, m_Deltapitch, m_Deltayaw ); //printf("raw -> %f %f %f \n",m_roll, m_pitch, m_yaw ); DeltaRotation.Pitch = m_Deltapitch; DeltaRotation.Yaw = m_Deltayaw; DeltaRotation.Roll = m_Deltaroll; /* FRotator actorRotation(0,0,0); DeltaRotation.Yaw = m_Deltayaw; AddActorLocalRotation(DeltaRotation); */ // Rotate plane Camera->AddLocalRotation(DeltaRotation); } // Call any parent class Tick implementation Super::Tick(DeltaSeconds); }
void ATP_FlyingPawn::Tick(float DeltaSeconds) { const FVector LocalMove = FVector(CurrentForwardSpeed * DeltaSeconds, 0.f, 0.f); // Move plan forwards (with sweep so we stop when we collide with things) AddActorLocalOffset(LocalMove, true); // Calculate change in rotation this frame FRotator DeltaRotation(0,0,0); DeltaRotation.Pitch = CurrentPitchSpeed * DeltaSeconds; DeltaRotation.Yaw = CurrentYawSpeed * DeltaSeconds; DeltaRotation.Roll = CurrentRollSpeed * DeltaSeconds; // Rotate plane AddActorLocalRotation(DeltaRotation); // Call any parent class Tick implementation Super::Tick(DeltaSeconds); }
void ASpaceRocksPawn::Tick(float DeltaSeconds) { const FVector LocalMove = FVector(CurrentXAxisSpeed * DeltaSeconds, CurrentYAxisSpeed * DeltaSeconds, CurrentZAxisSpeed * DeltaSeconds); // Move Craft's Root Component through X,Y and Z axis (with sweep so we stop when we collide with things) // Note that orientation/rotation of root component always remains fixed, but the craft's static mesh + camera do the rotation. AddActorLocalOffset(LocalMove, true); // Calculate change in rotation this frame (For player's mesh and camera) FRotator DeltaRotation(0, 0, 0); DeltaRotation.Pitch = CurrentPitchSpeed * DeltaSeconds; DeltaRotation.Roll = CurrentRollSpeed * DeltaSeconds; DeltaRotation.Yaw = CurrentYawSpeed * DeltaSeconds; // Rotate Craft PlaneMesh->AddLocalRotation(DeltaRotation); // Call any parent class Tick implementation Super::Tick(DeltaSeconds); // Are the fire button(s) pressed? If so, do something about it /* if (primary_on) { // Primary Fire // Just some test(ish) code to start with // Fire, if firerate not breached if (lastfired <= (this->GetWorld()->GetTimeSeconds() - WeapInfo.getFireRate(PlayerInv.weaponInventory[weapon]))) { // ** TODO ** Can we make this all more efficient? // This big gets the Location an orientation of the player //FireLocation = ShieldMesh->RelativeLocation; FireLocation = RootComponent->RelativeLocation; FireRotation = PlaneMesh->RelativeRotation; // This gets the default direction the fire should head from the PlaneMesh forward vector. FireDirection = PlaneMesh->GetForwardVector(); //Now we calculate various offsets to the player position, so we are not firing from the middle of the mesh // - Mid Left //FireLocation_Mid_Left = FireLocation; FireLocation_Mid_Left = FireLocation - PlaneMesh->GetRightVector() * 105.f; FireLocation_Mid_Left = FireLocation_Mid_Left + PlaneMesh->GetForwardVector() * 50.f; FireDirection_Mid_Left = FireDirection; FireRotation_Mid_Left = FireRotation; // - Mid Right //FireLocation_Mid_Right = FireLocation; FireLocation_Mid_Right = FireLocation + PlaneMesh->GetRightVector() * 105.f; FireLocation_Mid_Right = FireLocation_Mid_Right + PlaneMesh->GetForwardVector() * 50.f; FireDirection_Mid_Right = FireDirection; FireRotation_Mid_Right = FireRotation; // - Infront and centre FireLocation = FireLocation + FireDirection * 205.f; // This now changes the FireDirection by calculating the direction the fire should head to hit where the player's crosshair is. if (!bIsThirdPerson) { LineTraceStart = FireLocation; LineTraceEnd = LineTraceStart + FireDirection * 10000.f; } else { LineTraceStart = TP_Camera->GetComponentLocation(); LineTraceEnd = LineTraceStart + TP_Camera->GetForwardVector() * 10000.f; } GetWorld()->LineTraceSingle( CrossHair_Hit, //result LineTraceStart, //start LineTraceEnd, //end ECC_Pawn, //collision channel CrossHair_TraceParams ); if (CrossHair_Hit.bBlockingHit) { FireDirection_Mid_Left = CrossHair_Hit.ImpactPoint - FireLocation_Mid_Left; FireRotation_Mid_Left = FireDirection_Mid_Left.Rotation(); FireDirection_Mid_Right = CrossHair_Hit.ImpactPoint - FireLocation_Mid_Right; FireRotation_Mid_Right = FireDirection_Mid_Right.Rotation(); CrossHair_Hit.bBlockingHit = false; // why I have to reset this, I don't know? UE bug? } // Finally, fire the appropriate weapon if (PlayerInv.ammo[weapon] != 0) { AActor * spawned; if (PlayerInv.ammo[weapon] > 0) PlayerInv.ammo[weapon] --; switch (PlayerInv.weaponInventory[weapon]) { case PHASEOID: spawned = GetWorld()->SpawnActor(AReconOneWP_phaseoid::StaticClass(), &FireLocation, &FireRotation); break; case PULSER: if (weap_cycle == 1 || weap_cycle == 3) { spawned = GetWorld()->SpawnActor(AReconOneWP_pulser::StaticClass(), &FireLocation_Mid_Left, &FireRotation_Mid_Left); } else { spawned = GetWorld()->SpawnActor(AReconOneWP_pulser::StaticClass(), &FireLocation_Mid_Right, &FireRotation_Mid_Right); } break; default: spawned = GetWorld()->SpawnActor(AReconOneWP_phaseoid::StaticClass(), &FireLocation, &FireRotation); break; } // Tag the projectile with the name of the Actor that spawned it. AReconOneWeaponProjectile* const TestProj = Cast<AReconOneWeaponProjectile>(spawned); if (TestProj) { TestProj->SpawnedBy = GetUniqueID(); } lastfired = this->GetWorld()->GetTimeSeconds(); } //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, GetFName().ToString()); //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("UniqueID = %d"), GetUniqueID())); // Increment weapon fire position cycle weap_cycle++; if (weap_cycle > 4) { weap_cycle = 1; } } } */ }