1
\$\begingroup\$

I am writing a really simple game with a scene (horizontal plane) and a human moving to the right of the plane (watching the simulation from the +z axis).

The scene contains some trees, which I am moving towards -x axis in order to create the animation effect (by adding a float to their current position).

The human just walks or runs with increasing/ decreasing the angular velocity of one of his legs.

The question comes down to, how can I combine this two entities in order to correlate the change of the speed of the human with the change of the variable that is responsible for making the animation of the scene?

Should I convert the angular velocity to velocity?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Sidenote, but it sounds like you should introduce a concept of scene coordinates rather than working in screen coordinates. In other words, rather then move the x position of the trees, keep the trees at the same location and move some form of camera to the right. \$\endgroup\$ Commented Feb 20, 2013 at 1:13
  • \$\begingroup\$ @CameronFredman: But moving the camera to the right I would have to have the terrain be expanding to the left of the x axis. Now, I just move the trees towards the x axis. \$\endgroup\$
    – Chris
    Commented Feb 20, 2013 at 9:37
  • \$\begingroup\$ I'm just saying. It's an unusual design to have the tree coordinates change, rather than the viewer in this situation. If it works for you, it works for you. \$\endgroup\$ Commented Feb 20, 2013 at 9:46
  • \$\begingroup\$ @CameronFredman: It's the first time writing my own game, so I am just learning(project assignment) :) \$\endgroup\$
    – Chris
    Commented Feb 20, 2013 at 10:30

2 Answers 2

3
\$\begingroup\$

Yes. Convert the angular velocity to a linear velocity. Use the human linear velocity to move the scene so that the scenery appears to move at the correct speed to the human walk speed.

You can convert to linear velocity by modeling the leg as a circle and using the length of the arc as the linear distance traveled. Or more simply, the angular velocity times the radius to the circle that represents the leg.

\$\endgroup\$
6
  • \$\begingroup\$ The bad thing is that the angular velocity at a walking speed is about 1250 which is a rather big value and the conversion is this: leg_height = 34.5(counted it at the scene moving the human, firstly the feet at the origin and then the start of the legs at the origin and then subtracting the 2 values -- I don't know if that's correct as well). So, leg_height * velocity = 43125 = speed. Then this speed * dt (=0.001) is the dx which I add to the current position of the trees (I know there is a better way to do this, but it's the first game I am coping with). \$\endgroup\$
    – Chris
    Commented Feb 20, 2013 at 9:43
  • \$\begingroup\$ Without units, those values don't mean much to me. You have to ensure you're using the same units throughout. 1250 sounds very high however. Are you saying that this method doesn't work? \$\endgroup\$
    – House
    Commented Feb 20, 2013 at 14:52
  • \$\begingroup\$ So I should be using the same increment to increase the velocity for the human and the terrain, right? \$\endgroup\$
    – Chris
    Commented Feb 21, 2013 at 12:09
  • \$\begingroup\$ You'd increase one or the other. If you move both then you're either making it appear as though the human is moving at double speed or they're not moving at all (depending on the direction you're moving things). \$\endgroup\$
    – House
    Commented Feb 21, 2013 at 15:42
  • \$\begingroup\$ This is what I've meant: Let's use a dx = -0.01 (negative due to the towards -x axis movement) x position increment for the terrain. Now, human, needs an angular velocity for his legs and arms. Here is where I am blocked.. \$\endgroup\$
    – Chris
    Commented Feb 21, 2013 at 15:48
0
\$\begingroup\$

Actually, you should have the velocity of the human (from the distance he moves and the delta time). Just use the velocity to move the ground to the opposite direction.

A question for you: If the camera is always following the human, the trees should be moving backward on your screen already. Why to you need another velocity to move it (which makes them move twice as fast as they should be)? Is it because you want to have different layes of background?

\$\endgroup\$
4
  • \$\begingroup\$ I think the problem is that the human doesn't have a velocity. OP needs to derive that from the leg motion. \$\endgroup\$
    – House
    Commented Feb 20, 2013 at 1:17
  • \$\begingroup\$ Unless you dont store the current position of the human, there should be always delta distance and delta time. Well, I am not saying this is faster than converting the angula velocity. Just if he already has the positions recorded, it's more straigth forward. \$\endgroup\$
    – laishiekai
    Commented Feb 20, 2013 at 1:23
  • \$\begingroup\$ I agree it's not a good way to organize the game, but if you're moving the human based solely off the leg movements, you'd have to convert it at some point. Unless you're doing some inverse kinematics to move the rest of the body too. \$\endgroup\$
    – House
    Commented Feb 20, 2013 at 1:28
  • \$\begingroup\$ The human is static at the origin and the environment is moving towards him (towards the -x axis, the human is looking to +x axis). Also, please look the comment I posted at the above answer for more info about my current implementation. \$\endgroup\$
    – Chris
    Commented Feb 20, 2013 at 9:44

You must log in to answer this question.

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