DevLog 20250722: (Special Project) Correct Physics Handling

DevLog 20250722: (Special Project) Correct Physics Handling

●9 ●128 ●195
calendar_today • schedule2 min read
— Originally published at dev.to

Overview

This little project deals with very simple (2D) right body physics. I will not spoil all the fun - essentially we control a 2D rocket. It would be fun to visualize data processing in such a fashion on a node canvas - kind of matches our Divooka visual programming scheme.

The hypothesis is that at least for 2-dimensional cruise control, a simple PID should be able to do something useful, and it's with that gut I am set to experiment a bit to verify my idea.

I've done some experiments in July last year but ended up not going far due to technical challenges.

Challenge

The challenge was to get it working properly with physics setup. Per RigidBody2D doc:

Force Doc

So is it relative or global? Without being able to visualize the force, it's a bit hard to tell also whether to use a force, or to use impulse.

Impulse Doc

It's been a while and I almost gave up - never really have time to create our own physics engine. But Godot got a new physics kernel and I thought maybe give it a try.

Some Inspiration

I've been doing some analytics and talking with ChatGPT on a new airship design that puts the air vessel at the bottom of the ship instead of hanging overhead - that inspired me maybe there are two things with current setup that's not working:

Schema

After fixing a few API calls related to GraphEdit get_children() change. I was looking at the force application code once again:

func _physics_process(delta):
# Remark: We are not using to_global directly because of issues with viewport transform
var left_anchor = %LeftThrusterCenterOfAction.position
var right_anchor = %RightThrusterCenterOfAction.position

# Remark: applied force is RELATIVE to the body (aka. current object)
apply_force(Vector2(0, -1).rotated(rotation + _left_engine_angle_degrees / 180.0 * PI) * _left_engine_thrust, left_anchor)
apply_force(Vector2(0, -1).rotated(rotation + _right_engine_angle_degrees / 180.0 * PI) * _right_engine_thrust, right_anchor)

Again, it's really simple once we figure out what's the right way to do things.

References

Want more #methodox & #simulation deep dives?

Join 6,134+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

2 Comments

0 votes
0 votes

More Posts

Hamiltonian Neural Networks: Physics as Inductive Bias

berkansesenverified - Nov 29

(Demo Game) Progress Record & Soft Intro to PID Controller

Methodox - Jul 23, 2025

The Physics Under The Protocols: A Developer's Tour Of Electromagnetism

AIAppsAPI - Sep 4

Quantum Mechanics For Developers: The Physics Under The Hardware You Ship

AIAppsAPI - Aug 26

Unjammable by Physics, Not by Architecture: A VLF Channel from Orbit

Sup4ikX - Aug 10
chevron_left
7.8k Points • 332 Badges
Toronto • methodox.io
94Posts
72Comments
7Connections
We are a vibrant start-up dedicated to revolutionizing personal computing for creators and professio... Show more

Related Jobs

View all jobs →

Commenters (This Week)

2 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!