0 votes

I've got a spherical 3d world and I want to add a VehicleBody. Up to now I've implemented a newtonian gravity system using move_and_slide on KBs.

Obviously I can't use move_and_slide with my VB and neither can I use the physics gravity settings as they're on the global y. I'd preferably like to use my existing methods which do the gravity, buoyancy and friction physics and spit out a Vector3 velocity variable.

I was surprised add_central_force seemed to have no effect at all:

if obj_1 is KinematicBody:
if obj_1 is VehicleBody:

Any suggestions?

Godot version 3.2.2
in Engine by (1,789 points)

Ugh, this is not going well. First I jumped for joy when I saw RB/VB had a mode for KB but it doesn't inherit with move_and_slide so I'm not sure what the point of it is. Then I saw they had this and gave a 2nd premature cheer:

func _integrate_forces(state):

But it has no effect at all. Yet the docs give the following example for a customer look_at function with a RB:

func look_follow(state, current_transform, target_position):
    var up_dir = Vector3(0, 1, 0)
    var cur_dir = current_transform.basis.xform(Vector3(0, 0, 1))
    var target_dir = (target_position - current_transform.origin).normalized()
    var rotation_angle = acos(cur_dir.x) - acos(target_dir.x)

    state.set_angular_velocity(up_dir * (rotation_angle / state.get_step()))

func _integrate_forces(state):
    var target_position = $my_target_spatial_node.get_global_transform().origin
    look_follow(state, get_global_transform(), target_position)

So why does set_angular_velocitywork and not add_central_force? Worse, sav is listed as a method for RigidBody2d and isn't in the docs RigidBody... I guess it's an omission, I'm taking it as read the tutorial code works.

Of course, I might just be kidding myself and this will actually need a custom physics module for the wheels to work but I can't see anything in the docs about how to do that...

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.