Toon Tanks : Moving up ramps?

I just finished the Toon Tank series and had a great time and am inspired to build off of where it ended to make a few levels. One of the main things I want to do is be able to have the tank drive up ramps to have a multi-floor level but with the current movement set up it will instead run into the beginning of the ramp and stop.

I feel like I may need to change the way of moving from AddActorLocationOffset() to another method, as it currently stops upon reaching any form of elevation, but I am unsure what. Any suggestions to point me in the right direction?

I’d suggest moving to a physics based approach using AddForce on the collision component.

Sorry to hijack this thread, I’m just about to finish “Toon Tanks” myself, but, how exactly do you make a new level and add it into the game? Like how to you get to finish off Level1 like we have right now, and get Unreal to load up the Level2 and so on. I really thought this would be the time for the lectures/lecturers to show us how to do it, but, it looks like it not going to happen, I have one Lecture left so it’s still possible we might be shown.

If you know how could you please explain how you are going to do it and/or provide a link to a YouTube tutorial showing how it’s done.

Another thing is that I tried putting a ramp (BSP) in the stage as is and accidentally fired a bullet at it, and Unreal crashed. Much more experimenting needs to be done before committing myself to a new level. Oh right, I made some terrain stuck the tank at the top of the hill and floating tank - so, yeah, not physics based. With physics set - on terrain some movement but when it topples over whoa - and on playfield no movement at all.

As always any help is greatly appreciated.


I’m pretty sure it’s mentioned in Simple Shooter? Possibly guidance in the end of section challenge. You can use UGameplayStatics::OpenLevel with the level name.

Thanks again :sunglasses:.

I’ll start looking into it straight away! This is one thing I would like to do before Christmas.

@DanM can you clarify a couple of things. Now the lecturer says “maybe you can add new level geometry and make the tank climb up ramps”, now is this impossible to do without going to a fully fleshed out physics system?

And just why can’t we just add physics to the tank (collision mesh) and add weight? I tried this and the tank will not move and I am really having trouble understanding why this happens?

Trying to add buttons to the widget to control the loading of levels. Talk about getting in over your hard

Did you move to a physics based approach using AddForce?

I was about to and I checked out a tutorial on YouTube about AddForce but all it was about was shooting blocks from the ground into the air! Cool, but quite a bit different. And he was using Addforce with a Vector.Up (something I remember from Unity), so, not particularly helpful with going along the ground and it looked like the AddForce was being continually applied again not all that helpful, when I only want it to accelerate to only a relatively small pace and stop particularly quickly.

So, I reached out to you, to see what was possible. And like why for instance with simulate physics and Mass In Kg set why I can only move backwards?!?. I will use the code that was in the video and apply it to what I have and see what happens, I might find a way to start making some modifications to get at least something cool happening. I’ll do that on Level2.

It’s getting VERY hot here now in Australia especially where I live, so, I only have limited time on the computer, when it starts reaching 30+ in the computer room trying to concentrate for any length of time is nigh on impossible at least for me.

In case I don’t get the opportunity I would like to thank you for all your help, and also to wish you a safe, and happy Christmas and prosperous New Year :sunglasses:.

I can’t use the AddForce() function! I don’t know how to access the StaticMeshComponent of the tank through the inheritance system we used from BasePawn. It’s probably quite easy but I can find out how.

I thought having this in the tank.h file:

UStaticMeshComponent *tankMesh;

then having this in the tank.cpp in the movement section:

	const FVector Up = this->GetActorUpVector();
		tankMesh = GetOwner()->GetRootComponent();
		tankMesh->AddForce(Up * 1000.0f * tankMesh.GetMass() );

That doesn’t work! So I’ve hit the wall.

I think you are running into an issue with GetRootComponent(). According to the documentation this will return a USceneComponent which will not have access to AddForce. You are gonna need to cast it to the right type to be able to apply the force. Also based on the hierarchy the root component should return a UCaspuleComponent not a static mesh which you still can use AddForce on.

I was able to get it to work in my project though I noticed some weird behavior, wobbling when going up ramps, when the collider when placed to low to the ground

Yes, you are right! Didn’t realise what I was doing until you pointed it out - and looked closely at the errors I was getting. I tried again coming up with something, but, the errors I was getting are well above my paygrade. I couldn’t even get the mass of the tank - that is something we learnt about in Building Escape - doh!. I’ll put this in the too hard basket and might comeback to it in the future if I ever learn how to use AddForce in another course with inheritance or in Simple Shooter. Unreal Docs are a basket case like me :smiley:. And Unreal forums are pretty useless too unlike Unity.

Congratulations :sunglasses:. You are pretty talented to do that with what we learnt in, “Toon Tanks”. Really good work!

Were you able to solve that? If not I would suggest trying a rotated capsule component for the “wheels”, two either side. Might be too small to really be a capsule shape though.

1 Like