# How can I create a realistic space ship click based controls like EVE Online using BGE?

How do I create a realistic space ship controls like EVE Online has using the Blender Game Engine? I'm trying to create a really small space RPG that's like a super-mini-version of (excluding the fact that it is not online) EVE Online. Click based controls; Click anywhere on in the empty areas of space around the ship and your ship will move to wherever you clicked or, for example, if I click in the space when my ship turns it leans to its side a little bit to give a realistic turn as a plane in real life would. I'm into python so that is always an option.

here is a link to my onedrive, be sure to access the untitled7.blend file to see my game and problems of course: https://onedrive.live.com/?cid=FFFC2E073E89A1F8&id=FFFC2E073E89A1F8!118

Here is a picture:

My ship has a red front and blue body. The landing and take off floor is green and my no gravity space is grey for now.

Here is all my controls and stuff below.

This picture shows the controls for the ship to move right that could not be shown from the image 2 above.

This is my physics stuff of my space ship.

Lastly, this is all my game engine status and stuff.

• I couldn't find any videos of EVE Online where a player is actually flying their ship, so do you want this to be a click-based controller to only rotate the ship along the Z axis, or fly in 3D space. May 26, 2015 at 16:17
• @X-27 Yeah, thats what us EVE Players do. If click on a portal and click jump then we jump to another part of space but if you get my point then yes, i intend on the ship to fly in 3d space. May 26, 2015 at 17:06

We need to start with a object that tracks to the mouse. Before we can do that, we need something for the object to track along. for this we will use a highly modified cylinder that resembles an inverted cone.

We need a shape like this so that the player can not ever move the mouse outside of the tracking zone.

Now the higher your mouse is, the further away it the mouse will be.

Once we have the basic setup, we can get the mechanics working.

By basic setup, I mean, a player, a camera, a tracking object, a subdivided plane (to show movement), and a cylinder. (The cylinder is irrelevant now, it can be no-collision object and be invisible. It only needs to be parented to the player) I am going to name the player Space Ship Cube and the tracking object Fly_To_Target We also need the camera slow parented to the player. the giant tracking field also needs to be parented to the player (still named Space Ship Cube)

Although I always try to avoid python if at all possible, sometimes it can not be avoided, and this is one of those times. we must add a script named Trackto.py

from bge import logic

def main():
scene = logic.getCurrentScene()
cont = logic.getCurrentController()

mouse_over = cont.sensors["MouseOver"]

if mouse_over.positive and scene.objects["Fly_To_Target"]['ActiveYesNo?'] :
tracker = scene.objects["Fly_To_Target"]
tracker.worldPosition = mouse_over.hitPosition
tracker.worldPosition.z += 1



There is some thing that this script references that currently does not exist. We need a Boolean property on Fly_To_Target named ActiveYesNo?

Of course none of this helps us if there is nothing to run the script. (don't worry, were going to make that now)

Now we if we press play it should look like this. (the plane has been hidden to show the tracking object and the field it runs along.)

Now we have a wonderful object tracking to the mouse. This is good, because now we can have the player (yes, It is Still named Space Ship Cube) track to it

Getting Space Ship Cube to track to Fly_To_Target is not hard at all. For now, this is all we need on the player. All this does is make it so when the Boolean property Drive? is true, the cube will move in the direction of our tracker object named Fly_To_Target

Now the Space ship cube will always fly to the the object Fly_To_Target we have tracking to the mouse.

There is one thing we need to change before we can test it. Because we are using linear velocity, there will be a significant overshoot problem. for details on why, view this question.

# Realistic Jet Flight

If you do not care why, and just want the problem fixed, set the damping on the Translation to .8

Now we can test it and it should work.

This is obviously not what we want, but it is very close. We can start by setting the Boolean property Drive? to false, and adding a mouse sensor and property actuator to set Drive? to true, because, when it is true, our space ship (Space Ship Cube) flies to object Fly_To_Target It is very important that Drive? is False when the game starts, or it will begin flying to Fly_To_Target as soon as the game is started.

Now if we test it, we should expect Space Ship Cube to remain still until we click

Unfortunately we still have the problem of Space Ship Cube indefinitely trying to reach Fly_To_Target. Do not worry, There is an easy fix for this. We can simply use that same mouse sensor to assign the Boolean property ActiveYesNo? to False

Now when we click, Fly_To_Target will no longer move.

That only fixed half of our problem. Space Ship Cube Still flies indefinitely. We still need something to make the cube stop moving once it reaches Fly_To_Target There is no need to worry, because I would not be writing this answer If I didn't know how to fix this. Remember the cylinder that we added earlier and strangely parented to Space Ship Cube? we will now make use of that. Until now it has been invisible, because we didn't need to see it. However, for illustration purposes, we can now make it visible again. While we are in the physics tab, we need to change a few settings.

I did not want to draw big blue arrows over the entire thing, but all of the settings there are important. It is very important that the physics type is set to sensor (detects collisions with static and dynamic objects but not other sensor objects) It is also important that the check box Compound is checked. this will basically make the collision bounds of the cylinder part of Space Ship Cube.

Of course for this to work the same check box needs to be checked on Space Ship Cube

Now we have a wonderful collision sensor! - Whoopee. Now we need it to do something. We are actually going to use it to detect a collision with Fly_To_Target

We can do this by placing the sensor on Space Ship Cube

If we test it, Space Ship Cube should stop once it reaches Fly_To_Target

Unfortunately, Fly_To_Target will not move again because we assigned it's Boolean property ActiveYesNo? to false, essentially deactivating it. If we want it to work, we need to assign it to True

This is easy enough to do by adding one extra logic brick.

Now we can test it and everything should work.

# Yay! everything works!

Until now I have been using a subdivided plane to show movement. In space however, there is no floor. so we can hide the plane. Remember, it is a no-collision object so it is effectively gone now. (Gravity is set to 0 so the objects will not fall)

If you had any trouble following that, (Don't worry, this even confused me the first time I read through it) you can always look at/take apart the blend file.

• By far!!!! I didn't even read anything you said yet because of lack of time but because your the infamous X-27, i have to say this is one hail of a job and answer you have. Excellent!!! Outstanding!!! Great performance!!!! You have my respect! Phenomenal job!!! You put true effort into your work! Keep like this and you'll probably have your own blender business ;-) May 27, 2015 at 22:37