[Feature Request] Space Sim or Aircraft Based 6DOF Template

Would be nice to see a good template featuring freeflight camera style for Space Sim or Aircraft based games.

they had this in the beta versions of ue4 and was one of the things (to me, not all that impressed with graphics related stuff) that made it stand out above ue3.
dont know why they took it out and replaced it with whatever that weird flying thing is supposed to be.

+1 for this, please bring it back Epic

You have to modify around 4 lines of code (actually delete them) and you have a 6-DOF template. You can also add another 10 lines to get convenient controls.

So 14 lines of code total.

Which lines of code would it be?

And I’m using the blueprints not the C++ stuff.

-Thanks

out of interest i looked at the flying template code to see what 4 lines to delete. nothing was obvious so i booted up the old beta to have a look (wow its so fast and light compared to ue4), anywayz…
cant say for blueprints but here is the code needed for 6dof flight. hope im allowed to post it, ill delete if not.


void AFlyingCPawn::Tick(float DeltaSeconds)
{
	// Calculate out how much to yaw this frame
	float TargetYawSpeed = YawInput * MaxYawSpeed;
	CurrentYawSpeed = FMath::FInterpTo(CurrentYawSpeed, TargetYawSpeed, DeltaSeconds, YawAcceleration); // This will smooth our interpolation
	FQuat DeltaYaw(FVector(0,0,1), CurrentYawSpeed * DeltaSeconds); // Rotate around world Z (up) axis

	// Calculate how much to pitch this frame
	float TargetPitchSpeed = PitchInput * MaxPitchSpeed;
	CurrentPitchSpeed = FMath::FInterpTo(CurrentPitchSpeed, TargetPitchSpeed, DeltaSeconds, PitchAcceleration);
	FQuat DeltaPitch(VehicleMesh->GetRightVector(), CurrentPitchSpeed * DeltaSeconds); // Rotate around vehicle right axis

	// Combine by multiplying to get overall change in rotation this frame
	FQuat DeltaQuat = DeltaYaw * DeltaPitch;
	// Apply to current rotation
	FQuat NewQuat = DeltaQuat * VehicleMesh->GetComponentQuat();
	// And update the mesh rotation
	VehicleMesh->SetWorldRotation(NewQuat.Rotator(), true);
	
	// Calculate new speed
	float TargetSpeed = bIsThrusting ? MaxSpeed : 0.f;
	CurrentSpeed = FMath::FInterpTo(CurrentSpeed, TargetSpeed, DeltaSeconds, Acceleration);
	// Calculate new location
	FVector NewLocation = VehicleMesh->GetComponentLocation() + (DeltaSeconds * CurrentSpeed * VehicleMesh->GetForwardVector());
	// Update the mesh location. 
	// Passing 'true' for bSweep means we will stop when we hit a wall.
	// Hitting a wall will also generate a ReceiveHit call, if we wanted to do something
	VehicleMesh->SetWorldLocation(NewLocation, true);

	// Call any parent class Tick implementation
	Super::Tick(DeltaSeconds);
}


void AFlyingCPawn::InputPitch(float Val)
{
	PitchInput = Val;
}

void AFlyingCPawn::InputYaw(float Val)
{
	YawInput = Val;
}



btw its a whole lot different to the current flying template.
possibly some functions ect have changed but it should give you the idea.

edit:
attached is the blueprint setup as a .txt file
copy the contents of the text file and paste it into a blueprint graph. you will have to go around it sorting out the variables, at least it gives you the idea how to do it.
only pitch and yaw but it should be easy enough to add roll if you need it.
good luck

Tomorrow I can put it in propably, or maybe at the weekend as I just did it today.

I appreciate that I’ll check it out. Thank you both!

Here you are: A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums

thanks cube2222
does it suffer from gimbal lock at all?
just curious as it doesnt use quats

Actually, I was really surprised about it, it doesn’t. I even expanded on it (wanna create a space sim) and had 0 problems with it. Everything just… worked.

cool ill check it out
thanks again

Problem is that this template would be just half the way to a usable environment.

There’s no AI for 3D space (volumes) and there are no plans for one. As it stands, Epic does not have a need for it, so unless the community creates it, or everyone overwhelms Epic with requests to do it, this template would just be good for PvP.

Just putting this out there, as AI for a flight sim was one of the questions to Mieszko in the recent twitch stream. :slight_smile:

no plans for flying ai?
seems a bit daft, surely that’s one of the basic features of any game engine, let alone one that claims to be one of the best next gen ect ect
so cars are extremely bugged, no softbody physics, no flying ai, mobile good as doesn’t work…
oh well as long as the graphics look good there’s no need for actual gameplay eh Epic lol
its udk all over again, nooooooo
guess they will leave it in a similar broken state when they spring ue5 on us, great

Hey tegleg,

There is some community made Flying AI

I will admit that flying AI is an priority for me. But in the mean time you can look into middleware such as MASA LIFE or Kythera.

Also UE4 is in a very early state compared to UDK which had years of work put into it.

yes udk did have years of work put into it, then they abandoned it completely broken. doesn’t fill me with confidence to keep using ue4.

AI is a fairly simple concept, I remember back in the early 1990’s I had computer with relays, microphone, soundcard, I’d speak to the computer and it would speak back in a very Star Trek female voice, I found that the longer the sentences and the more the AI had to compare sentence structures the more error prone it was and that was the wrong was to go, the older models were faster, more accurate and produced better results.

Using hashtables with the Key/Value pairs made things even faster for voice command usage and recognition was improved with simple CTRL key press when ready to talk to computer to isolate all the background noise.

This is completely unrelated, I’ve also done graphics programming and all the engine type of development stuff back in day, I know when it comes to 3D vs. 2D it’s very simple to convert from 2D to 3D and back with basic logic, you normally use the same code then merge the results to produce for a 3rd axis and that’s really all there is to it.

You do not need the Quaternion and Spatial Axis Rotation calculations when dealing with just the Euler angles.

What one would do if you were a programming later using a higher level language such as VB (Early VB.NET/ASM Base) or C++ several years ago is simply look at the Windows SDK code for DirectX, which has most the combined camera code already in it, I’ve got the source code for it and have in the past compared the orbital freeflight concepts and mixed mode camera’s, you’d work with OpenGL back then as a test bed.

Unfortunately, it’s much harder today to just look at a simple Java or Flash based physics or math example with the 2D ship and mouse or joystick control examples and then quickly convert because it’s harder to find those examples now.

Over the past few months I haven’t found any of the ones I’ve seen before, and the rest archived into the now old XNA project and X-Wing Fighter and Mech Warrior source code, where are they???

It had the chase and nose cone camera setup, dolly camera’s, pretty much what you see in Bigpoints Battlestar Galactica online game and also the stuff covered by 3D Buzz and for Unity 3rd person projects.

But where’s the few line math examples with the rest now?

If we take all that knowledge today and keep it simple, you could say it boils down to the proper usage of either sin or cos, lol.

I hadn’t had problem with Gimbal lock early on, someone mentioned it, I had it solved in early code, I think I fixed it by using all double precision values and making sure the references were correct, I dunno why some people would lock frame rates that’s what caused all the bottlenecks and lagged response when you add more players.

The index value was off by 1 because the programmers doing social networking code were used to programming in a language that had the array storage variable starting with the bounds index value of 1 instead of 0, can’t remember if it was Myspace or Facebook or both that had that.

Anyways, it was the same fix for the graphics when finished, I forgot to switch and check for proper UBound values once, lol. Was more confusing by 3 different values, with -1 index, 0 index, and 1 index and for constant, the value should’ve been 0, and -1 upon re-usage to zero out any existing data in the structure and the existing storage array elements. (List of common programmer errors 101!)

I used Quaternion with the early matrix math, it was very responsive with mouse input at the time with how the rotations are combined and values updated and graphically with a concept of your proper page flipping of the right buffers (visible/non-visible) and the inner window message que usage, but in the end that really is related to the structure of your code itself and how the rendering passes are handled, it needs to stay away from being serialized and stay asynchronous, with optimized code usage from the get go, eliminate any possible code breakage or loops (use while/end loops never for loops) that cause processing to jump out from the main code blocks, never lock framerate (use asyncronous time based approach), and keep the blocks seperated, core input logic should never go in the render block for graphics.

To keep it simple for the AI logic, just locate some simple ship examples that use 2D logic that are mouse or keyboard controlled, if you can find any of the DarkOrbit game type examples go with those, you can easily convert those to 3D as the code samples via Flash only cover a few lines of code and basic math, and that’s it.

You also can get the tweening/interpolation and most your other common math from that, which some is also included in the Unreal Engine Documentation via the Content Examples, you just need to think about how to use that to accomplish what you want to accomplish and take it from there.

It also handles the direction vector multiplied with the position and the distance to object and ship movement, (ship thruster speed increase, weapons, and movement slowdown), reminds me, I used to use a tool called Terragen to create the skyboxes (snapping the view angles at 90 degrees and also to help create the higher resolution textures for landscape) and convert them into Skyspheres, probably better to do using particle fields in UE4 or with program like Blender and/or a paint program now.

Oh the content example template for the Top/Down has it as well where you point and click with mouse and player goes to that position, the math for something like that would essentially be the same.