## Making a character walk around on uneven terrain

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

### Making a character walk around on uneven terrain

I can't find any functions or methods to nail this the right way. I'm trying to make an easter game and having some problems - it is my first time making characters in-game.

Anyhow, my problems are:
• The character is moving in the right direction, but I literally set velocity, so it isn't falling or walking up surfaces when necessary unless you stop walking
• Character falls when climbing the high surfaces, while it should remain upright at all times.
I attached the love file. The file with the problem is \scenes\game\main.lua, line 225 is where the love.update is. Please, suggestions or tips would be appreciated. Thanks.
P.S. The pink-red box is the character: I'll be replacing it with an image soon. Just pretend, lol.
Last edited by Bannana97 on Sat Mar 23, 2013 3:08 pm, edited 1 time in total.
notencore
Prole
Posts: 16
Joined: Wed Mar 13, 2013 6:08 pm

### Re: Making a character walk around on uneven terrain

Code: Select all

character["_.Object"].Body:setLinearVelocity(-100, 0)
You're setting the Y velocity to zero. Set it to a variable that contains the current force of gravity on the player. (If there's a platform under you it should be zero.)

Hope I could help, and if it doesn't work I apologize.
nooblord
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

### Re: Making a character walk around on uneven terrain

Yeah, that helps a bit. But I still would like to know if it's possible, and if so how, to force the block to remain upright, instead of falling down.
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Making a character walk around on uneven terrain

I think you could call this method on the player body right after you create it: Body:setFixedRotation