2
\$\begingroup\$

I'm making a game in stencil where players walk form left to right along randomly generated walls. I cant use waypoints, since the walls' shapes and positions are unpredictable.

Here's a descriptive sketch:

a player walking on walls

The red line is the player's path. The red circles are what I thought might make good waypoints until I scrapped the idea.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I embedded the sketch and made some corrections and clarifications. Did I get them right? \$\endgroup\$
    – Anko
    Mar 20, 2013 at 21:15
  • 1
    \$\begingroup\$ What is your question? \$\endgroup\$ Mar 20, 2013 at 21:19
  • \$\begingroup\$ I'm really lost in how to implement something like this,rotating and changing forces only work to climb walls,changing gravity affects all characters on scene,i need a kind of pathfinding to make the character stick to the walls. \$\endgroup\$
    – MetalLord
    Mar 20, 2013 at 21:45

2 Answers 2

1
\$\begingroup\$

Depending on what you actually wish to do , either 1) Change the gravitation upon colision with a wall, so it faces "into" the wall.

2) Add high friction for walls, equal 1 to the body fixture. It allows sticking to walls.

\$\endgroup\$
0
\$\begingroup\$

You can make a raycast from your character into all all four directions. If you only hit the ground then you don't have to do anything. If you hit a wall or the ceiling you add a weld joint to your character and the wall. You destroy and recreate the joint inside your update loop, so the character can move, but is tied to the wall/ceiling and doesn't fall down. There are still two tricky parts left.

  1. Corners: When you come to a corner (two ray casts hit a wall) you must switch the wall on which you create the joint, depending on the direction you are walking to.
  2. Walking direction: When you walk around a corner, you must track the direction you are walking to, so you can press forward all the time and follow the shape of the wall.
\$\endgroup\$
4
  • \$\begingroup\$ Most of that is unnecessary. Easiest solution change the gravity vector. \$\endgroup\$
    – vallentin
    Oct 23, 2013 at 15:58
  • 1
    \$\begingroup\$ Which will change the gravity for every body, not only the player. Since the OP didn't specify, I cautiously made the assumption. \$\endgroup\$
    – zilluss
    Oct 24, 2013 at 6:19
  • 1
    \$\begingroup\$ Then it's still the easiest way, because if the OP want the world to "keep" its original gravity, then simple use 2 gravity vectors, one for the player and one for everything else. \$\endgroup\$
    – vallentin
    Oct 24, 2013 at 6:54
  • \$\begingroup\$ You mean a force on the player that's applied in every update? Hadn't thought of that, but sounds like a much better idea. \$\endgroup\$
    – zilluss
    Oct 26, 2013 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .