Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Brainstorm: Spacecrafts for FPS-RPG

Author
Message
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 3rd Jun 2015 19:12 Edited at: 3rd Jun 2015 19:17
Hey all,

I'm working on a sci-fi fps/rpg game with a bit of simulation in a pixel art graphic style like "Delver" and "Eat, Drink, Slay" (an AppGameKit Game). I've already got a lot of work done, full scene editor, additional tools, core engine and I'm now working on actual game design documents.

Basically, the "game world" are independent scenes (space sectors, worlds, etc.) that the player can explore.

I've got most bases covered, but I'm a bit stuck on spacecraft. Smaller spacecraft would be done like the classic "Wing Commander" and "X-Wing" and "Tie-fighter" games.

My biggest issue are larger spacecraft, because I want it to be fully controllable but also be able to walk around and interact with if from FPS view.

Moving around an object is no problem, but when it's filled with interactive objects and NPC, the problems arise.

I figured to split the larger crafts in to two "scenes". The actual ship in space and an additional scene for the interior, but that would also mean that there is less interaction between the two scenes, from simple looking out the window, which would not match if the ship has moved, to other situations happing outside/inside the ship.

I seek relative simple and lightweight(on CPU/GPU) solutions.

All suggestions are welcome! Please discuss!

Regards Sph!nx
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 4th Jun 2015 07:57
I believe the easiest way would be to treat everything in the ship as if it's not moving, calculate everything then transform those resulting variables by the ships position and rotation.

"Get in the Van!" - Van B
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Jun 2015 10:24
I think you'd have to use some sort of parent-child setup, like say the player is inside a ship, you would position the player object at the ship position, then rotate it to suit the ship orientation, and then add local movements to that. It might be just a case of storing the coordinates of the player and applying those after positioning the object with the parent object.

This means that if the ship is moving or rotating, the objects inside will still be in the same local orientation and position... kinda like adding the objects as limbs, which brings me onto a second idea.

If you position an object and rotate it to suit the parent, then it'll be dead centre of the ship, so if you then affect the limb offset then that becomes a local movement - like setting an objects limb 0 position to 100,0,0 means it would be 100 units to the right of dead centre, and stay there no matter how the parent or ship was orientated. This might be the more elegant solution, but it kinda interferes with things like object collision.

With either method, you would need an airlock to get a nice transition when going outside... I guess you could see it as going in or out of an artificial environment, you need a transition so you can work out the limb offset or whatever when entering a new environment. I guess if a ship is damaged and has no environment, then you would just float around inside it, if it was rotating violently then it might be real dangerous, but it lends itself to realism that way.

Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 4th Jun 2015 16:28
Hey, thanks guys!

Yeah, I figured it would need a parent-child system. I also thought about setting the (child) objects rotational point to the same point as the parent object (ship) and move it simultaneously... if that's even possible.

Still thinking about the best setup. Thanks for the input guys and if you have more thoughts, I'd be happy to hear it!

Regards Sph!nx
Morcilla
22
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 4th Jun 2015 17:41 Edited at: 4th Jun 2015 19:02
Sph!nx, you might want to disable player spaceship's Z-read, if it is going to be always the nearest object in screen.

Other than that, please follow Sasuke's advice or you'll soon experiment arithmetic precision issues when positioning the camera and/or the user spaceship.

Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 4th Jun 2015 17:42
The best way would be to set up rotation matrices and use look/up/right vectors to move.

The reason for this is it makes transitions easy. When in artificial gravity, the players up vector can simply transition to the ships up vector so no matter what angle the ship is at, it will correct itself to it. This also applies to outside the ship. You can used the ship meshes normals to affect the up vector of the player and this will make it so you'll always be walking around the surface of the ship at the right angle.

Anything that sits on the ship you just rotate to the ships angle and transform it's position by the ships rotation matrix. If anything on the ship is rotating then you multiply the matrices (shipRot x entityRot) to get the final angle (what you'd have to do with the camera).

I will have to create an example

"Get in the Van!" - Van B
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 4th Jun 2015 19:45
Thanks for the input, guys!

@ Sasuke
I do not have that much experience with vector or rotation matrices.If you would create that example, I'd be very grateful!

Regards Sph!nx
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 4th Jun 2015 19:45 Edited at: 4th Jun 2015 20:47
Here's a quick example of what I was talking about, little bit of a rush job so naming of things won't be amazing but it has the affect. You'll notice that players position and rotation is local to the ship, as is the same for the ships entities and this is how you should treat them.

What the code produces...


[Requires IanM's Matrix Plugin]


Quote: "I do not have that much experience with vector or rotation matrices"

They are quite useful so definitely take up using them. They're not that complicated. An easy way to understand them is just recreate the vector/matrix commands in code and you can see how they work (or read up on them). This is how I learnt them. Now I use the commands cause they are so much quicker than doing the math.

"Get in the Van!" - Van B
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 5th Jun 2015 14:30
Ohw, wow, thank you very much, Sasuke. It runs smooth and seems to do what I need. Excellent!

I'll dissect the code when I return home. I'll let you know how things go.

Thanks again!

Regards Sph!nx
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 5th Jun 2015 18:50
Sweet! If you need any help with the code of going through what things are or how they work, let me know

"Get in the Van!" - Van B
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 6th Jun 2015 17:49
Thanks mate.

I'm not there yet to have it implemented in my game. That might take a while, but I will be sure to let you know when I do. By that time I also might start a WIP thread. I'm working on it alone so things do take time.

The example you made is very good, although I do need to read up on vector and matrix commands to fully understand it. When I do, I'll create a little demo, like yours but in the context of my game project. With some models and stuff.

Your help is very much appreciated, Sasuke. You rule!!

Regards Sph!nx

Login to post a reply

Server time is: 2025-08-09 02:29:54
Your offset time is: 2025-08-09 02:29:54