Question about the Attach Node Script in V4.4.1

Godot Version

V4.4.1

Question


Hello everyone,
I’m learning Godot from a FreeCodeCamp video that was uploaded about a year ago (v4.0). In the video, there’s a scene showing how to choose the CharacterBody2D: Basic Movement template without a built-in script, but I can’t seem to do that in Godot v4.4.1.


Has anything changed?

Hi,

I created a CharacterBody2D node in a test scene. I right clicked on the node and chose ‘attach a script’.

In the dialogue that appears I clicked “Built-in script” and above it I clicked template and chose the basic movement template as you can see below.

If that is what you were talking about (which I think it is) you just need to click the built in script option to access the templates.

Hope that helps

PS I am currently using 4.3, not 4.1, you should upgrade ASAP. In fact I too should really upgrade now to 4.4, so do as I say, not do as I do :slight_smile:

Firstly, thanks for your response. As I mentioned earlier, I am using V4.4 and I am trying to avoid the built-in script because I’ve heard that it is unstable and difficult to modify later on.
Does this mean that I can no longer use a template without enabling the built-in script?

Oh I thought they always were, but they are not. In 4.3 you can just load a template into a new script when attaching it without it being “built in”. Well I did not know that.

Is it not working then in 4.4? It is in 4.3

I just downloaded 4.4.1, created a new project, added a characterbody2d and loaded a template when attaching a script (not built in).

So yes, it seems to be working fine, and exactly as it always did.

Just in case you need it here is what is in the template:

extends CharacterBody2D


const SPEED = 300.0
const JUMP_VELOCITY = -400.0


func _physics_process(delta):
	# Add the gravity.
	if not is_on_floor():
		velocity += get_gravity() * delta

	# Handle jump.
	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		velocity.y = JUMP_VELOCITY

	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	var direction = Input.get_axis("ui_left", "ui_right")
	if direction:
		velocity.x = direction * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)

	move_and_slide()
1 Like

So you mean you are able to call the template without built-in? That’s weird, let me try to rebuild my part and check. Thanks anyway, and will let you know later.

So I created a new characterbody2d real quick, with one collisionShape2d and one animateSprite2d. Yes, you’re right, it works, I can call it without build-in. Let me work out what the issue really is in my formal case.

So now I know the reason. I have no idea why there is a player.gd in my player file, which I believe I did not create such before. When the script, player.gd exists, I can do nothing but follow it only. Using template becomes not available.

So all things work, Case closed. I do apperciate your help!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.