missing information about physics

hi again Gio. while I have a fuse to deal with the engine I will create themes))

So this time we will talk about the plug-in of physical interactions.

I just want to note that there is nothing in physics at all. no tutorials or documentation

for example, I have a problem-there is a conditional construction that increases the player's speed

	this.setVelocity(this.getVelosity().x+ delta, this.getVelosity().y)

and I want to completely translate it to physics by making a dynamic body

I mean I'm just basically adding momentum or power :

	this.getBehavior('PhysicsObject').applyForce(some force)

but these results are similar to rocket simulators with extremely inertial motion. it would be logical to take away the force / momentum - but there is nothing in the documentation

t..e my goal is to create a completely similar movement as it is in physics-rotation and acceleration, with a slight inertia deviation.,

in other words I need to simulate the movement of a jet object with an engine at the back and very responsive to turns

of course, you can use the force or momentum of the opposite vector when you click the turn or deceleration button - but how to understand where 0 is. In other words-how to get the value of the current forces of the object?

of course I reached into the source code to see something about the force and saw the file wade_src/ physics/forces.js. but I saw something else there-this. particleExplosion. and of course immediately wanted to blow something up - but alas, it did not work. я получаю ошибку что l.getBehavior() не является функцией etc. is there an example -how to blow something up with these functions?



All 6 Comments

Hey krumza

The documentation for PhysicsObjects is here.

There are also a couple of ready-made examples that you can look at to copy/paste some code. In the editor, use the orange button at the top to browse repositories. There is a repo called "Physics Objects" and it contains a few things that you can drag and drop into your scene, then you can inspect the code. There isn't a spaceship example, but I think there is something with a car that could be interesting to understand how to use complex Physics Objects.

Long story short, in your case you probably want to use PhysicsObject.applyImpulse() to control your spaceship.

I have to be honest, I don't remember off the top of my head how to use particle explosions, but I'll try to have a look and see what I can find.


I cant see something as "getSummaryForce" or "getAllImpulses"


There is no such thing. You can get the object's velocity via SceneObject.getVelocity(). For what you are describing, you need to know the object's velocity.

Forces are applied only once when you call PhysicsObject.applyForce(f). In that case, for that frame, the total force applied to the object is f. If you also have gravity, then the total force is f + gravity.

But like I said, I think you won't need that. Apply an impulse in a direction that is opposite to the object's velocity if you want to brake.



I'm afraid to go into the negative and give a negative speed to the subject in this way - so I ask if there is a way to find out the sum of all the forces acting in the moment on the subject



The only force that is acting on your objects at any time is gravity, if you are using gravity. Forces do not cumulate, so when you call PhysicsObject.applyForce(f), at that time, the sum of all the forces acting on that object is f + gravity. The next frame, the sum of all forces acting on that object is 0 + gravity.

There is no way to get that value via the PhysicsObject interface, because typically you know what the sum of all forces acting on your object is: if you have just called PhysicsObject.applyForce(f), then it is f + gravity, otherwise it's just gravity. However if you think it could be useful to have a PhysicsObject.getForces() function to retrieve that value, I don't see why we couldn't add it.

Think of "impulse" as "change in linear momentum", that is mass * velocity. There is no way you can get the object to move into the opposite (negative) direction, provided that the impulse you apply is smaller than the object's mass multiplied by the object's velocity.


thank you, I'll think it over. Such questions arise from the fact that there is no time to try in the app and play with the parameters.

P.S. it seems that there were high grades in school in physics and mathematics, but I understand that this is not the case  although it has been at least 20 years since

Post a reply
Add Attachment
Submit Reply
Login to Reply