[SOLVED] Jumping/Impulse with momentum using nodes


#1

When I use the “third_person” template (which uses the ThirdPartyController Bundle Trait) and add a simple “Jump/Impulse” node (shown in picture below) the character jumps in the direction it’s moving (with momentum, not controlled in the air.) This is great.

If I add that same jump node to a project that uses nodes to control the character (like the logic_controls example, or my current node setup in the post below) the character only does a vertical jump no matter how it’s moving.

Note: The reason I add the “Gate” and “Has Contact” node is because I don’t want to actually control the character in the air, I want it to be like a real jump where it’s based on the direction the character is moving, like it is when using the ThirdPartyController Bundle Trait.

How can I jump in the direction I’m moving using nodes not a Bundle Trait or Haxe script?.

Thanks for your time, much appreciated.

simple-jump-allen



#2

Note: These should “On Keyboard: Down” not Started, I’ve changed that.

I’m guessing this momentum effect requires velocity and the ThirdPartyController script specifies velocity somewhere?

Do I need to add a velocity node somehow? If someone has added velocity to the “logic_control” example using nodes that would be great to see.


#3

Yeah, I’m trying to figure out essentially the same thing… that is, how do I apply a force to an object when a key is pressed. I’ve tried using “add force” and “add impulse” nodes with keyboard nodes to trigger them, but so far… nothing.

image

Anyone want to help us out? :grin:


#4

I’ve modified the “logic_control” example so it moves by velocity and it jumps just how I want (with momentum but not controlled in the air) my new modified “Move Forward” node is in the picture below.

You have to release the up button before pressing the jump button at this stage, I’m guessing that can be fixed by a minor node change (working on it.)

This velocity works the way it would in a car (it continues to roll forward when releasing up) and if you use it for a character running you would need to add nodes decelerating/stopping quickly after releasing the button that moves it forward.

logic_control_velocity


#5

Wow. That seems like a complicated tree just to apply a force on pushing a key (even if you overlook the two nodes for checking if the object is touching the plane object).

I don’t quite get why it’s necessary to get the transform, turn the transform into a vector, multiply the current vector with the desired change and then set the velocity, instead of just applying a force/impulse and letting the physics engine do it’s thing.

Granted, I’m brand spanking new to Armory, so there may be concepts I’m missing, however I’ve been making games with the BGE using Bullet’s physics system for years, so I get the general concepts.

I really wish that each of the logic node descriptions in the docs had just one simple 3-node-or-less example… When I understand them better, I may just have to add that myself…


#6

The “Vector Math” node is just there so you can change the speed of the car, it still works with out it.

And the “Vector From Transform” and “Get Transform” nodes are there so it moves the way the car is facing (which changes using the left and right keys).

To simply apply velocity in a certain direction you would not need most those nodes, I’ll try making a setup like that.

(I’m new to this too, I wouldn’t know this from scratch but looking through the examples I’m understanding what does what as long as it’s there to reference and play around with.)


#7

Well, you’re still ahead of me.

So far, I haven’t even managed to get a physics controlled body to move. Not once. :thinking: I’m assuming that you have your car object’s physics properties set to rigid body with active type selected and dynamic ticked?


#8

Edit:

Yeah that’s right and anything it’s moving on top of (the ground) needs to be an active rigid body but without dynamic ticked.

Downloading these examples will help.

The logic_control one uses all nodes traits (not bundled or haxe scripts) you can see how they do it.

One thing I’d forget at first was to actually attach the node in the “Armory Trait” section of the object tab.


#9

Thanks. I figured it out though. I needed to attach the logic tree to the object. I just assumed that if I created a logic tree with the object selected, that it would be attached, but… nope. Going to Object > Armory properties > Add > Node > Name of my logic tree, got it working. :smiling_face_with_three_hearts:


#10

Exactly what I did at first. I just assumed it accessed all nodes all the time.


#11

Is this problem solved? If not, can you send me full logic node setup?
Also, why do you want to make your car jump?
If you don’t want it to decelerate it quickly than you can decrease it velocity over time.
If you want to see how car physics would work, then you can check vehical template, and make nodes system based on the how velocity and stuff are applied there.

@Armored_Blob Well, Docs and more examples are being worked on.


#12

Yeah, absolutely. I understand that. I was thinking more about how I could contribute later, considering my recent experiences as someone new, rather than intending any criticism. I know Armory is a young project. I’m impressed with how far along things are already…

PS @allenm If I may hazard a rough guess as to your original problem… It sounds like you’re setting the velocity (x,y and z) to a set vector, rather than just adding to the z. This would cancel out any velocity in the x/y axis…


#13

@BlackGoku36 @Armored_Blob My navigation was originally using the “Translate on Local Axis” on one project and “Translate Object” on the other, I’m guessing neither of those provide momentum for for an impulse/jump and I needed to be using a “Set Velocity” node? That’s what I’m doing now it seem to be working.

I didn’t necessarily want a car to jump that just happened to be the best example on GitHub using control nodes.

When I eventually make a game (very new to this) I want a character that uses his actual momentum to jump, eg. if he runs towards an object he doesn’t just jump vertically, I’m getting that now I’m using “Set Velocity” instead of “Translate on Local Axis.”

What can I do to allow my character to jump without first releasing up or w?


#14

I believe that this setup does what you’re after:
image

It essentially moves the character (cube) left/right using the left right keys, and makes them jump using space. If they jump, they retain their horizontal momentum, but the contact node makes sure that they can only change their momentum (either horizontal or vertical jumping) when in contact with the ground.

Note, the shortcoming of this is that it only checks for one ground object, so if the cube is say, on top of another object, then they’re unable to move/jump.

This would be fixed by replacing the contact node with a node group which actually detects if any object in a specific collision group is below the cube.


#15

Thanks, what are the drop-down values on those three “Impulse” headings?

I don’t think this will read the jump though if another button is down, it’s a similar setup to what I have (but my velocity vectors are relative to the direction of the camera/player)


#16

do it like this. when player press w then make a bool and assign true to it that is check if player is moving?
then check if player is pressing space and use branch there, in bool value use the if player is moving value. in true then apply impulse with linear velocity and if false then just apply impulse.

Hope this help.


#17

.3 for left and right, and 4 for jump. You may need to adjust these based on the scale / mass of the objects in your scene.


#18

I’ve got it a little different due to the camera and turning mechanism but it does seem to let me press jump and the move button at the same time, is that simply because the “Has Contact” node is shared now?


#19

The only thing that sharing the “has contact” node does, is make it a little more performant (as the engine only checks for ground contact once instead of 3 times).

What makes the real difference is that this is using impulses, which are additional. So for example, if you apply an upwards impulse, it doesn’t set the horizontal velocity to zero. (At least, that’s my guess)


#20

Ok. What exactly is the difference between setting a certain velocity straight ahead and setting a certain impulse straight ahead? Is it just the way the speed is calculated? It’s calculated with mass in mind with the impulse and not with the velocity?