Jump to content

3D sidescroller movement


Rick
 Share

Recommended Posts

Let's say I want to create a sidescrolling game in 3D. Let's also say I want to not use the character controller object but instead just use the model mesh to move around. I want the character to also be able to move somewhat "up" and "down" (think double dragon). So if I start out on the x axis being forward and backward this moving "up" and "down" would actually be the z axis.

 

I don't want to use MoveEntity() but PositionEntity() for learning some math sake, so I'm trying to use vector math here to figure out how I can handle this. I don't want to hardcode the axis that "forward" means positive X because I'm thinking about having the character be able to rotate and go down other paths which would screw that all up. The camera would rotate with him to always keep the sidescrolling perspective however.

 

So I'm trying to figure out how can I keep things relative?

 

So initially "forward" is down the positive X axis and that would be the D key. So even if I allow a 90 degree rotation at some point the D key would always be "forward", but that might be down the Z axis if I allow rotation.

 

The other thing is that A would rotate the character and could be looked at as "forward" also but it's really "backward" with the model just rotated. My main issue is that the W and S key would originally move in the Z axis, and be a strafing effect. When I'm facing "right" down the positive x W would strafe relative left, but when I'm facing "left" down the X axis at first (but remember this could be the Z axis also if I rotate down another path) W would need to strafe relative right.

 

I guess I don't even know if any of this even makes sense :) It's kind of confusing in my head.

 

Any help or pointers would be nice.

 

Thanks

Link to comment
Share on other sites

I would keep learning and game development seperate things. When I need to learn and test something, I make a seperate project, and when it works then I copy it back to the game code.

 

I would make all movement with physics. You could have invisible walls around the scene, so that the character is jailed into a 2D world.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

I understand what you would do :) but I'm asking specifically in the way I phrased it. I don't want to take another approach, I'm more interested in learning with the vector math and was wondering if I could start a dialog with some people who are willing to lend a hand at the given approach I'm taking.

 

You could have invisible walls around the scene, so that the character is jailed into a 2D world.

 

That's not really an issue I have. I know how to do that, it's more the vector movement that I'm curious about.

Link to comment
Share on other sites

Try this my hint:

 

- when you press move control, define movement vector for player not from model (Z axis vector), but from camera axis vectors, because camera is always oriented toward screen and looks on level/player from side when we talk about "side scroll" control.

 

Pseudo math code for movement:

 

to right/left:

Pivot_pos = Pivot_pos +/- Camera_X_axis_vetor

 

to up/down:

Pivot_pos = Pivot_pos +/- Camera_Z_axis_vetor

 

with this, player movement always looks like "side scroll", aligned to camera view.

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...