0 votes

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.

in Engine by (30 points)

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.

1 Answer

0 votes

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.

by (60 points)

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.

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 Frequently asked questions and 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 [email protected]tengine.org with your username.