Impuse vs Velocity

I don’t really understand the difference between impulse and velocity and motor. @JR01 ?

Also I’ve seen people (like JR01) use different words like “var” which I believe is variable in javascript, but idk how to use it. I’d like a list of these words and what they do. They aren’t in the help section.

2 Likes

Velocity sets an object’s speed directly, while Impulse and Motor just apply a force to an object, causing it to accelerate.

3 Likes

You can set values to a name in the expression by using var. I’ve used them in many bundles, but you use them like.

var Xspeed = A;
var Yspeed = B;
Xpeed + Yspeed

Here is a haxe list for math operators
Math - Haxe 4.3.1 API

2 Likes

So you can do everything with velocity if you want to? Like jumping?

Also both of you are solutions so…

1 Like

oh I think I get it. I was trying to understand your code. Here’s what it says in the expression:

var n1 = A+B;
var list = [400, 180, 0, 400, 270, 225, 315, 270, 90, 135, 45, 90, 400];
list[n1];

so it’s basicly just running the program you write in it?
So you declare a variable “n1” which is A+B, then declare a variable “list”, an array, and fill it up, then you output the "n1"th number of the “list”. I’ve done some programming.

That makes sense, but which line will it return the number? Does it just return the output of the last line? I’d assume so

2 Likes

Those variables just are set using those lines. You have to call upon them again in the expression to use them.

Basically JR codes using HAXE inside an expression

4 Likes

What exactly do you mean here? Nothing special, right? Just how variables work normally.

2 Likes

Looks like its one of my directional movement code (possibly from Witch?).

So the expression itself works like your making a function (which is a little ironic because you can make functions inside this function), but that means that the first line that makes an output will be the output.

For example, if you use return statement in your code, it will kill the expression and output the return value. And if you do math and not set it to a variable, it will output that math and kill the expression.

The one thing about expressions is that its not live code and resets once it outputs. So every eval input, it has to create those variables i made in the expression and run the code.

2 Likes

I see.

var n1 = A+B;
var list = [400, 180, 0, 400, 270, 225, 315, 270, 90, 135, 45, 90, 400];
list[n1];

Because the first two were just making the variables, so the last one is the one that is outputted.

Are you saying that you can also do it manually? Like this?

return list[n1];

This effects the runtime and efficiancy, right, nothing else.

2 Likes

list[n1] and return list[n1] should have the same results.
That line isn’t letting the expression move to the next line so that is the output there.

2 Likes