Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Several Days Work

But not the whole day on any of them. Who has time for that? Actual gamedevs? Ha!

Contrary to the frequency of my dev logs (I was planning on updating every time I work on stuff--good habits take practice I guess), I have been working on Hopes N' Dreams. I've made some progress! I have definitely encountered a few significant issues as well though. I want to try to use a different format for this log (problem/solution) so here goes:

Problem 1: Moving like someone is watching

The first and most important problem I have encountered was how to make the character's analog stick motion base itself off of the camera facing (e.g., if you hold forward on the analog stick, the character moves away from the camera, regardless of which way the camera or character are facing). I parented the camera to my character so that it would rotate with the character (which created a couple other problems I still haven't solved).

Parenting

Parented like this! Notice the meshes I added! I'll fix the yellow only later

I got the camera rotating correctly, but nothing I tried would make the character take the camera's orientation. After hours of pounding my head against the wall, I stumbled on this bit of code:

var a = get_transform().basis
set_linear_velocity(Vector3(a.x.z, a.y.z, -a.z.z) * speed)
# which I implemented a little bit differently to calculate 2 different axes together
# fb_mul is the forward/backward analog stick float, lr_mul the left/right
var a = get_transform().basis
var fb_tot = Vector3(a.x.z, a.y.z, -a.z.z) * -fb_mul
var lr_tot = Vector3(a.x.x, a.y.x, -a.z.x) * lr_mul
set_linear_velocity((fb_tot + lr_tot) * (run_spd / run_accel))

This was so cool to find out! I still don't really know what it is doing though (I mean, generally I get it--using the current transform as the basis, but what exactly is it getting? I'll probably have to spend some time printing out the values to see whats really going on.). It does work though.

Problem 2: Falling at the right times

Why is it when I get one thing working, I break something else? As soon as I got the motion figured out, I found out that my character would not continue to fall when I was using the analog stick to move (or rather, that it would continue to fall whatever rate it was falling when I started to move the character). My first fix for that was to disable the stick input while not colliding with the ground objects, but that was pretty unsatisfactory. One of the best feelings in platformers is when you jump and realize you can't possibly make it, but holding the stick towards your target platform gives you just enough to make it there.

I ended up replacing that quick fix with a state-ish system. The problem was that I had been resetting the y component of the Vector3 when I was augmenting the velocity:

# It doesn't take a genius to see why this didn't work
set_linear_velocity(Vector3(new_x_velocity, 0, new_y_velocity))

The non-broken way (read: less-broken/jerry rigged way) was to send the analog inputs to a different sub-function if not touching the ground, and re-implement gravity to the character while he is falling. There has to be a better way to do this--if you know what it is please don't hesitate to shame me publicly and explain it.

Problem 3: Continuing moving

A third problem (one I haven't fixed) is a problem with vector resolution (at least I think it is). When the player rotates the camera while he is already in motion, the motion ceases until the camera is no longer receiving inputs. So if you are falling at 1000 mph and you turn the camera, it stops your vertical and horizontal motion pause until the camera button is released. This would be such a cool effect if I had tried to make it happen (unfortunately, it's just a crippling bug instead). I suspect the problem has to do with my separate resolutions of the camera and player motion (in a way they are both player motion though because of the way I implemented the camera). If you have any information at all about the solution to this bug call 1-800-fix-mrdudeiii's-problem-now right away! (or just leave a comment)

Thanks for reading!