I cannot get the tanks to move despite my code and BP being exactly the same

So I’ve followed along and as far as I can see I have everything pretty much the same (aside from the Bug where parts of my Tank disappear and resetting the Physics material and Tank Friction)

Heres my code for the Movement:


#include "TankTrack.h"
#include "Math/Vector.h"
#include "TankMovementComponent.h"

void UTankMovementComponent::Initialise(UTankTrack* LeftTrackToSet, UTankTrack* RightTrackToSet)
{
	LeftTrack = LeftTrackToSet;
	RightTrack = RightTrackToSet;
}

void UTankMovementComponent::RequestDirectMove(const FVector& MoveVelocity, bool bForceMaxSpeed)
{
	// No need to call Super as we're replacing the functionality
	auto TankForward = GetOwner()->GetActorForwardVector().GetSafeNormal();
	auto AIForwardIntention = MoveVelocity.GetSafeNormal();

	auto ForwardThrow = FVector::DotProduct(TankForward, AIForwardIntention);
	IntendMoveForward(ForwardThrow);

	auto RightThrow = FVector::CrossProduct(TankForward, AIForwardIntention).Z;
	IntendTurnRight(RightThrow);
	//	UE_LOG(LogTemp, Warning, TEXT("%s vectoring to %s"), *TankName, *MoveVelocityString)

}

void UTankMovementComponent::IntendMoveForward(float Throw)
{
	if (!LeftTrack || !RightTrack) { return; }
	LeftTrack->SetThrottle(Throw);
	RightTrack->SetThrottle(Throw);
	// TODO prevent double-speed due to dual control use
}

void UTankMovementComponent::IntendTurnRight(float Throw)
{
	if (!LeftTrack || !RightTrack) { return; }
	LeftTrack->SetThrottle(Throw);
	RightTrack->SetThrottle(-Throw);
	// TODO prevent double-speed due to dual control use
}

and the Header file:

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/NavMovementComponent.h"
#include "TankTrack.h"
#include "TankMovementComponent.generated.h"

class UTankTrack;

/**
 * 
 */


UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class BATTLE_TANK_API UTankMovementComponent : public UNavMovementComponent
{
	GENERATED_BODY()

public:
		UFUNCTION(BlueprintCallable, Category = Input)
		void IntendMoveForward(float Throw);

		UFUNCTION(BlueprintCallable, Category = Setup)
		void Initialise(UTankTrack* LeftTrackToSet, UTankTrack* RightTrackToSet);

		UFUNCTION(BlueprintCallable, Category = Input)
			void IntendTurnRight(float Throw);

		virtual void RequestDirectMove(const FVector& MoveVolocity, bool bForceMaxSpeed) override;


private:
	UTankTrack* LeftTrack = nullptr;
	UTankTrack* RightTrack = nullptr;
	
};

After looking through stuff for several days, I cannot see where I’m going wrong here

What are you getting for the logs? Are Intend__ being called?

I don’t think Intend is being called as the UELOG is not showing my latest message on Intend Move,

I also noted that my NavMesh is acting weird and going above my scene no matter what I do(this I believe is the issue and it looks to be an issue with the tracks):

Even after changing the collision on the track I’m still getting this, I can’t delete the Tracks from the BP as Unreal crashes when I do

In Unreal do Build > Build paths (or navigation, forgot what they call it)

When I rebuilt the Nav Maesh, I now get this:

It looks like something is colliding with the navmesh before the Tracks,

Also I downloaded the Git Commit for this and its the full game, so I cannot even just switch to that and continue in this case (even to just have a clean project to go from)

Ah hang on, I think the issue was that the NavMeshes Z Value was a Positive Axis and not set to 0 (as in X,Y,Z being 0,0,0) for some reason, as soon as I reset it worked (though bobbling all over the place, which will be sorted in a future video as mentioned)

Thanks Dan as always!

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

Privacy & Terms