How to change scale of scene from another scene

so i chained a scene (the player) to the main scene (the level) and i got a script that when the player touches something, it gets smaller, and i thought that would be possible by doing

func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("Player"):
Global.JUMP_VELOCITY = -100
Player.Scale.x = 0.5
Player.Scale.y = 0.5

but this gives me an error.

image

any way to fix this? any help is appreciated!

First of all, please put your code between ``` - one on the top and one on the bottom. It makes reading your code much easier.

func _on_body_entered(body: Node2D) -> void:
	if body.is_in_group("Player"):
		Global.JUMP_VELOCITY = -100
		Player.Scale.x = 0.5
		Player.Scale.y = 0.5

Second, are you using GDScript or .NET? Because capitalization matters, and I think you’re using GDScript, but it looks like you’re using C# because of your capitalization choices.

Third, this should solve your problem:

func _on_body_entered(body: Node2D) -> void:
	if body.is_in_group("Player"):
		Global.JUMP_VELOCITY = -100
		body.scale.x = 0.5
		body.scale.y = 0.5

yep, it did, thank you so much!

1 Like

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