Hi, First of all, thanks for fast replay.
Right now it’s only a tank in the world, you can observe 2 tanks in the image, first one near to camera is the new tank I spawn and the second tank is the old tank with AimingComponent.
yes, MovementComponent is fine but AimingComponent still attached to the old tank.
Answer:
first set camera movement in blueprint :
then in PlayerControl class I calculate Hit location with LineTraceSingleByChannel and send it to AimingComponent in AimingComponent I calculate velocity with SuggestProjectileVelocity and set Barrel and Turret in AimingComponent with connecting it to blueprint ( as the image you can find in brief ) and with some extra calculate to achieve desired speed for barrel and turret and send them to barrel and turret for moving them .
interesting is I spawn the projectile in AimingComponenet class, however, the old tank move barrel and turret but the second tank spawns and shoots the projectile !!!
if you still need codes too, let me know, I will copy them ASAP.
Troubleshooting
1)
if you check the spawn code I use // for destroy() cause when I destroy it I receive errors and warnings :
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:GetColorAndOpacity_0:00EE
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:GetColorAndOpacity_0:00EE
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:GetColorAndOpacity_0:00EE
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:GetColorAndOpacity_0:00EE
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:GetColorAndOpacity_0:00EE
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:GetColorAndOpacity_0:00EE
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:GetColorAndOpacity_0:00EE
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:GetColorAndOpacity_0:00EE
LogScript: Warning: Attempted to access Aiming via property BP Aiming Component Refrence, but Aiming is pending kill
Aim_C /Engine/Transient.UnrealEdEngine_0:GameInstance_9.Aim_C_9
Function /Game/Widget/Aim.Aim_C:Amo_left:001E
-
I connect the Re-Spawn cod with action key input to the player whenever tank rollover can Re-Spawn it again.
but the interesting thing is if I shoot the old tank the new tank will die with it too.
-
I didn’t get that one, my view changes with the new tank but in new tank barrel and turret not moving but in the old tank turret and barrel still move with aim.
you mean to put the second camera?