Instancing a RigidBody and applying impulse to it's local rotation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 2-Zons

I’m new to GODOT coming from Unity. I’ve never used python so just learning the scripting style.

I would like to make a cannon. The cannon will rotate and elevate. When fired I would like to create an instance of a node (cannon ball) and give it an impulse based on the relative position of the cannon.

Specifically:
Syntax for creating an instance of a node?
Syntax for applying impulse to said node based on another node’s position and rotation?

I’m sure this is pretty basic stuff but I’m also just learning to navigate GODOT’s documentation resources as well.

Thanks.

Have you tried looking at any of the demos? Maybe one of those has an example. The one for a Kinematic Character may be helpful.

Ertain | 2019-05-31 04:27

:bust_in_silhouette: Reply From: bluemage

I’m still new myself. But you might be able to sort of do what you want with AnimationPlayer add new animation. add property track and then click on the AnimationPlayer then the node that has a translation with your cannonball. you can then click the little key next to the property in inspector if done right and it will make a keyframe in the AnimationPlayer.

You’ll also probably need a kinematicbody or maybe rigidibody will do to. I’m not sure. Hope this helps somewhat.

I am certain there is a way to create instances of nodes in code. I have found the impulse method for rigid body’s. I just need to see an example of using it with relative position and angle. I definitely don’t wan’t to use animation to solve this. Thanks for the quick reply though.

2-Zons | 2019-05-31 02:04