https://godot.readthedocs.io/uk/latest/classes/class_rigidbody.html
Godot version: 3.0.4
Issue description:
Currently, there is no local version of apply_impulse()
. This function currently only applies an impulse on the global coordinate system. What I would like is for a new function, perhaps named apply_impulse_local()
, to be added, which applies an impulse in local coordinates. Using apply_impulse_local(Vector3(0,0,0), Vector3(0,0,-1))
would always push the object "forward", regardless of which direction it was facing.
This would be in a similar vain to translate()
vs translate_object_local()
. The first works with the global coordinates, while the latter works with the object's local coordinates. If you used translate_object_local(Vector3(0,0,-1))
then it the object would move "forward", regardless of which direction it was facing.
My current work-around (note that it's in C#):
ApplyImpulse(Vector3.Zero, transform.basis.Xform(Vector3.Up * movementScale));
Proposed syntax to do the same thing (also C#):
ApplyImpulseLocal(Vector3.Up * movementScale);
With applying impulses, specifying "local" can be confusing because:
Do you have four different functions for the four different options? Or do you pass in two flags to set them? Either way, it is likely to be confusing to see either multiple flags or multiple functions.
Because the "workaround" you post is exactly what the engine would do behind the function call, to me, it is the correct way to do it (on the user side).
Local position and force in particular is worth supporting, as a common use case, modelling objects that have thrusters or other force things on their body. Local position and global force seems useful but less common (magnet force pulling part of an object toward another object?), and I have no idea why you would want global position and local force.
I think having an apply_impulse_local
work with the force and position both locally is intuitive ("local" = "everything is local"), and gets most of the convenience value because it would be the most common case for local forces. There's no reason to try to support the other modes you came up with.
Am recreating a space game using thrusters - the ability to apply forces locally along the objects z easily would be very useful. (for me)
+1
+1
@jdjddjdj @KingKone GitHub has the ability to thumbs-up a post instead of commenting "+1".
Also, I think I'll tackle this issue myself for 4.0 along with fixing some related API inconsistencies.
Please, find a solution to this!
Hey Aaronfranke! yes - will use the thumbs up button next time : ) Doh!
I am a non-coder, but reasonably fluent in Max/msp and QC. All of my scripting is using Visual script - Is there any chance you (or anyone) could show me the "translated into visual script" version of the example you posted at the top?
I have paused my work in godot based on not being able to figure this one single (deal killing) problem out. Attached is a pic my current Visual Script. Everything works exactly as i want except the (non)local nature of the direction of thrust
Your snippet is below
thanks for any suggestions
jd
My current work-around (note that it's in C#):
ApplyImpulse(Vector3.Zero, transform.basis.Xform(Vector3.Up * movementScale));
@jdjddjdj Thanks. That will fairly nicely work...
Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.
The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.
If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!
Most helpful comment
Am recreating a space game using thrusters - the ability to apply forces locally along the objects z easily would be very useful. (for me)
+1