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
Before you make a thread asking for help, read this.
Post Reply
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Making a character walk around on uneven terrain

Post by Bannana97 »

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. :awesome:
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

Post by notencore »

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

Post by Bannana97 »

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.
User avatar
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

Post by Robin »

I think you could call this method on the player body right after you create it: Body:setFixedRotation
Help us help you: attach a .love.
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Making a character walk around on uneven terrain

Post by Bannana97 »

Robin wrote:I think you could call this method on the player body right after you create it: Body:setFixedRotation
That or :setAngle(0) at a constant rate. Thanks for the help.
Post Reply

Who is online

Users browsing this forum: pgimeno and 12 guests