How to achieve movement like this

Here's the place to get help and discuss features. The focus is on the C++ version, but generic questions are welcome.
Posts: 3
Joined: Sun Jul 02, 2017 7:10 am

How to achieve movement like this

Postby Thoms2 » Sun Jul 02, 2017 7:59 am

Press button and with mouse you aim where to jump.

*Slow movement/ jumps
To achieve this I reduced simulation gravity, not sure if thats the proper way. Maybe play with Step time? But thats too tedious.

When start walking to direction I want to robot to speed up slowly and reach its max speed. I believe that must be achieved using motor joins (wheel joint)

What I try. The walking speed is still like in typical platformer.

Code: Select all

        if(Gdx.input.isKeyPressed(Keys.D)) {

            if ( vel.x <  5 ) force =  40;
            desiredVel =  5;
            velChange = desiredVel - vel.x;
            force1 = player.getMass() * velChange / (float)(1/60.0);


If I reduce force then it speeds up slowly but sometimes body gets stuck since Im not using wheel.


I try to use

Code: Select all

  player.applyLinearImpulse(new Vector2(0,player.getMass()*4),player.getWorldCenter(),true);

However, I guess I need to use some kind of impulse. applyForce maybe? To achieve the same as in gif I think that I need to aim with mouse and get angle then apply impulse to my body to jump toward that angle. How far it will jump depends on how far I place mouse pointer from my character. Jump shouldnt be influenced how fast you was walking before. It should apply thrust to pointed direction.

Any ideas :?:
Last edited by Thoms2 on Tue Sep 12, 2017 11:09 am, edited 2 times in total.

Posts: 7
Joined: Sun Jun 25, 2017 9:05 pm

Re: How to achieve movement like this

Postby CrowbarBarian » Mon Jul 03, 2017 8:14 pm

I've made a try at coding what you are looking for in the testbed. There is a lot of work to be done with tweaking values and to implement a projected trajectory dot display. But I think I've gotten the fundamentals down for you.

The file:
(7.84 KiB) Downloaded 10 times

Just put it in the Testbed/Tests folder and modify your Testbed/Tests/TestEntries.cpp to look a little like this:

Code: Select all

#include "Tumbler.h"
#include "VaryingFriction.h"
#include "VaryingRestitution.h"
#include "VerticalStack.h"
#include "Web.h"
//new line
#include "Player.h"

TestEntry g_testEntries[] =
   {"Player Test", Player::Create}, //new entry
   {"Character Collision", CharacterCollision::Create},
   {"Tiles", Tiles::Create},
   {"Heavy on Light", HeavyOnLight::Create},
   {"Heavy on Light Two", HeavyOnLightTwo::Create},
   {"Vertical Stack", VerticalStack::Create},
   {"Basic Slider Crank", BasicSliderCrank::Create},

Then just recompile the testbed and play around with it. It should be self-explanatory.

I've made the base of the player object a wheel so it won't get stuck on things. The central player body definition has fixedRotation = true set to keep it upright. I've mostly gotten jumping right, but I can't quite figure out the best way to disregard player motion while jumping.

I hope this helps a little. ;)
By the way, what game is that gif from? Looks interesting...

Posts: 3
Joined: Sun Jul 02, 2017 7:10 am

Re: How to achieve movement like this

Postby Thoms2 » Tue Jul 04, 2017 4:55 am

Thanks for your reply! The game is "Steel Sentinels" from FunOrb (made by Jagex). It was forgotten 7 years ago. When it was active there was like 1-2k players online daily fighting each other or doing missions. One of the best games I ever played. Most interesting for me is the movement, its slow so gives player time to react to things and dodge shots etc. In gif I showed only jumping but also you can fly and you can plan your trajectory for like future 3 air jumps.

Just checked your example and it answers alot of my questions. Now I need to tweak gravity little bit, add some delay before jumping, calculate trajectories.
Last edited by Thoms2 on Fri Sep 08, 2017 9:24 am, edited 1 time in total.

Posts: 7
Joined: Sun Jun 25, 2017 9:05 pm

Re: How to achieve movement like this

Postby CrowbarBarian » Tue Jul 04, 2017 10:21 am

Try using

Code: Select all

b2Vec2 scrcoord = g_camera.ConvertWorldToScreen(m_player->GetPosition());

scrcoord will have the position of the player in pixels onscreen.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests