Tank is not shooting

HI,
I´m getting the following errors:

\TankAimingComponent.cpp(15) : warning C4996: ‘UActorComponent::bWantsBeginPlay’: bWantsBeginPlay was inconsistently enforced and is now unused Please update your code to the new API before upgrading to the next release, otherwise your project will no

\TankAimingComponent.cpp(81) : warning C4458: declaration of ‘AimDirection’ hides class member

It compiles, but the tanks are not shooting. I allready copied the code from github.

Thanks Stefan

Those aren’t the reasons your tank isn’t shooting. Do you have your project on GitHub?

There’s another thread (somewhere) about this: bWantsBeginPlay has been deprecated since the lecture was taped, though it should still be harmless except for the strange warning. Most likely removing references to bWantsBeginPlay will stop the warnings and unless actually using it for something, won’t affect the code.

Declaration of AimDirection hides class member: means two or more variables have the same name and you might be reading/updating the wrong one as a result. Changing the name slightly (with refactoring in VS2015, hit CTRL-R twice) can fix that and let you see that you are working with the “right” copy. It could also mean you defined AimDirection twice when you only wanted to once.

2 Likes

I found out that the component is not ticking. I Use Unreal Version 4.14. Maybe i need to downgrade Unreal?!

void UTankAimingComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{

UE_LOG(LogTemp, Warning, TEXT(“Aim ticking”))
if ((FPlatformTime::Seconds() - LastFireTime) < ReloadTimeInSeconds)
{
FiringState = EFiringState::Reloading;
}
else if (IsBarrelMoving())
{
FiringState = EFiringState::Aiming;
}
else
{
FiringState = EFiringState::Locked;
}
}

Put this line:

PrimaryComponentTick.bCanEverTick = true;

in the constructor

// Sets default values for this component's properties
UTankAimingComponent::TickComponent(){

}

bCanEverTick, unlike the bWantsBeginPlay, isn’t deprecated and is necessary.

it was already in it.

Can we see your full code?

It is exactly the same code as in the course, i copied it.

Do you have your project on Github? We can’t exactly help you if you aren’t providing more information.

I have a very slow internet connection, so it would take forever to upload it to github.
It is no coding problem since i downloaded everything from github to rule out any errors i made
. the ticking is not working in 4.14. I´m now working with 4.12. and everything is fine.
I thank you all for your efforts.

I have similar problem in 4.13.2 - aiming component not "ticking"
In constructor I set PrimaryComponentTick.bCanEverTick = true
In constructor for Tank actor set PrimaryComponentTick.bCanEverTick = true too (and tried with false)
No ticking at all for component
But BeginPlay is calling. Thought that component is not registered - and added RegisterComponent in BeginPlay - logged with error - component already registered.
Set breakpoint in UActorComponent - TankMovement has ticking (however in code there is no line for ticking for movement component), but breakpoint not hit with aiminig component.
In release notes for .13 couldn’t find anything related for ticking component.

Update:
In editor for MovementComponent I found many checkboxes with ticking behavior, for aiming (actor) component - there is no corresponding checkboxes. Where its placed for new versions?

Update2:
Set “Auto Activate” in Activation group for Aiming Component and TickComponent called correctly.

Do you have your project anywhere?

I ran into the same problem in 4.14.2. Dan have you tried latest version? I’m going to check fregate’s solution.

Hopefuly this saves someone else some time. I tried “Auto Activate” pre fregates comment without luck.

I’ve been struggling getting TickComponent to fie for hours.

I downloaded https://github.com/UnrealCourse/04_BattleTank/tree/19f5bf1ce11ca745b626aa120280e654fdc27a65
Upgraded in place and tested TickComponent and it worked.

Then I went back to my project copied the contents of Aiming Component from Dans project .cpp and .h files into mine.

Still it did not fire the TickComponent. Very strange.

So I opened up Tank_BP and deleted Aiming Component and added another. (Not forgetting to rewire Both the Event Graph and Input Setup)

Saved & Compiled and Magically started receiving TickComponet.

5 Likes

well I went it to UE editior “Aiming Component” switched projectile_BP to the default, then switched back again (in the details section) and it works, some problem with refreshing I guess.

Hey Dan,

I ran into the issue of my Aimingcomponent not ticking as well…
What fixed it was removing the aiming component in my blueprint and wiring everything connected to the old AimingRef to the new one.

I had a same problem about bWantsBeginPlay. I have 4.15 version and in my Project TankAimingComponet has not bWantsBeginPlay declaration at all. and I put it myself in TankAimingComponet’s Constructor and then I got the same Error

I deleted bWantsBeginePlaye and problem was solved

it’s question for me why bWantsBeginPlay is not in my TankAimingComponent and by adding it I got Error

@stevencheatham

thank you very much Sir am on 4.19 and by removing component and adding it back into the BP tank file it worked Like a charm so weird it does not refresh correctly… i will remember that for next time

Privacy & Terms