momentum based movement

So I want to make a controllable character with momentum based movement, I tried I tried servo controller in the motions tab, but that caused me a great deal of problems. For starters, you slid around way to much for my liking, so I went into the materials tab and turned up the friction, but then what would happen is if you were running up against a wall whilst suspended from the ground you’d stick to it. Is there a way to fix either of these problems simultaneously, or is there another way I can do this without having any prior knowledge of scripting?

say X+ is forward

copy = own.localLinearVelocity.copy()

#remove sliding sideways
own.localLinearVelocity.y*=.5

add sideways movement to forward
if own.localLinearVelocity.x>0:
    # minor loss on forward momentum from turning
    own.localLinearVelocity.x+=abs(copy.y)*.425



You would only want momentum-based movement if you wanted to take into account the masses of objects (which I believe defaults to 1 in Blender).

You might mean force-based movement.

As BluePrintRandom noted, you could use linear velocity.

I like applying force though because you get a nice ease-in/ease-out for starting and ending motion (you can also control the speed of the ease-in/ease-out).

Applying force, however, is more of a math problem than a programming problem. i.e. How much force do I need to apply on an object for it to reach 2m/s in 0.5s?

I’ll leave it at that.

Good luck!

how do you control the ease in and out?

https://www.youtube.com/watch?v=DqcfXM_08xI something like this is what I’d like.


            # set the z velocity so we have gravity
            z = own.localLinearVelocity.z 
            
            # set x and y velocity (stops sliding).
            x = 0.0
            y = 0.0


            if forwards: 
                y = 2.5
            elif left:
                x = -2.5 
                
            if jump:
                z = 4.5     
                  
            # set the speed               
            own.localLinearVelocity = [x, y, z]  

Basic example, you can add acceleration in it as well if needed

how do you control the ease in and out?

To control ease-in/ease-out you need to answer the math question I posed to you in my reply:
How much force do I need to apply on an object for it to reach X speed in Y seconds?

To answer this question you need to know the current velocity of the object, you need to know the final velocity you want, and you need to have a time to get to that final velocity. The ease-in/ease-out is dependant on the time. The time to go from the current velocity to the final velocity is your ease-in time. The time to go from current velocity to 0, is your ease-out time.

There are established physics formulas to answer these questions, I’d look up “acceleration formulas” on Google. You’ll find formulas that will tell you how to calculate acceleration given an initial velocity, a final velocity and a time. From there, you know “force = mass * acceleration”. So you can use “applyForce(mass * acceleration)” in python and get your ease-in/ease-out.

Repeating what I said at the end of my question, I have no knowledge of python.

Well, you can do all I said with logic bricks, but it’s a lot more cumbersome (and not entirely possible). You kind of need to pick the lesser of both evils: the struggle of learning python or the struggle of using logic bricks for complex tasks.

I would highly recommend learning python, because if you want to create anything nearly as complex as that Doom game you mentioned, you need to learn how to program - that’s the harsh reality. Learning python can also help you adapt to different game engines where logic bricks don’t exist, so that’s another plus.

I beg to differ with that second to last statememt sir.https://m.youtube.com/watch?v=E4gt85kRsSg this is what I’m working on.

aweseeker he is right - Wrectified - the original version - collapsed under the weight of logic bricks.

with clever programing and a few scripts you can emulate the behavior of thousands of bricks

(for instance here is me making sensors in game using python) -

so far - rayVision cone sensor and ray sensor and collision sensor :smiley:

Hey - all power to you. All I’m saying is that you can use Python to write logic that would be hassle to do in logic bricks. I used to use logic bricks for everything, but I moved towards python, and I now I use a totally different engine.

If you want save/load functionality, you’ll probably need python at some point. If you want to do multiplayer with split screen - you’d need python. If you want to use algorithms to calculate linear velocity, you need python for ease.

Even if you’re going to avoid those things I’ve mentioned above, I’d still recommend learning a programming language, if not for Blender, but for other engines.

Yeah, I agree, its just not something I can poor time into learning at this point.

check this out

Attachments

python_start.blend (412 KB)