Undefined Variables in Player/Player.gd #1

Closed
opened 2021-03-21 17:20:32 +00:00 by Zanark · 7 comments
Zanark commented 2021-03-21 17:20:32 +00:00 (Migrated from github.com)

Hi @Squatnet

I love your project, I'm using it as an inspiration to work on a pet project of mine. I wanted to ask a few things from you regarding your code.

func setMod(col):
	modulate = Color(col.r,col.g,col.b)
func _physics_process(delta):
	fr += 1
	get_input()
	velo = move_and_slide(velo)
	## send to server here
	rotation = (velo.angle())
	if fr > 10:
		get_parent().get_parent().sendPos({"x":position.x,"y":position.y})
		fr = 0

The variables modulate and rotation come out as a undefined on the Godot Editor. May I know what these are exactly. I checked the Project Settings on Godot and did not find any singletons declared so what exactly are these.

Thanks a ton in advance. Awesome project!

Hi @Squatnet I love your project, I'm using it as an inspiration to work on a pet project of mine. I wanted to ask a few things from you regarding your code. ```gdscript func setMod(col): modulate = Color(col.r,col.g,col.b) ``` ```gdscript func _physics_process(delta): fr += 1 get_input() velo = move_and_slide(velo) ## send to server here rotation = (velo.angle()) if fr > 10: get_parent().get_parent().sendPos({"x":position.x,"y":position.y}) fr = 0 ``` The variables `modulate` and `rotation` come out as a undefined on the Godot Editor. May I know what these are exactly. I checked the Project Settings on Godot and did not find any singletons declared so what exactly are these. Thanks a ton in advance. Awesome project!
Squatnet commented 2021-03-21 17:28:56 +00:00 (Migrated from github.com)

Hi there, modulate and rotation are both built in to certain nodes in godot
editor. I'm unsure as to why they are undefined, as rotation and modulate
properties exist in all 2d nodes, Are you using 3d nodes or UI nodes?
Modulate comes from base class CanvasItem
https://docs.godotengine.org/en/stable/classes/class_canvasitem.html#class-canvasitem-property-modulate
and Rotation comes from base class Node2D
https://docs.godotengine.org/en/stable/classes/class_node2d.html#class-node2d-property-rotation
modulate is simply the quick and dirty way I was setting the color for
players
rotation is simply how I was setting which way the player sprite was facing.

Hope this helps.

Hi there, modulate and rotation are both built in to certain nodes in godot editor. I'm unsure as to why they are undefined, as rotation and modulate properties exist in all 2d nodes, Are you using 3d nodes or UI nodes? Modulate comes from base class CanvasItem https://docs.godotengine.org/en/stable/classes/class_canvasitem.html#class-canvasitem-property-modulate and Rotation comes from base class Node2D https://docs.godotengine.org/en/stable/classes/class_node2d.html#class-node2d-property-rotation modulate is simply the quick and dirty way I was setting the color for players rotation is simply how I was setting which way the player sprite was facing. Hope this helps.
Zanark commented 2021-03-21 18:13:46 +00:00 (Migrated from github.com)

Hey! Thanks a ton for the quick reply!

Yes I'm using Spatial nodes for my project. Okay I got what modulate and rotation are now. Will search for equivalent properties in the spatial node for these and list them here once I find 'em post which I will close this issue 👍🏼

Hey! Thanks a ton for the quick reply! Yes I'm using Spatial nodes for my project. Okay I got what modulate and rotation are now. Will search for equivalent properties in the spatial node for these and list them here once I find 'em post which I will close this issue 👍🏼
Squatnet commented 2021-03-21 18:28:34 +00:00 (Migrated from github.com)

Hi, I'm pretty sure Spatial node have no equivilant property for modulate, Instead you would change the properties of materials applied to child meshes (hope that makes sense)
rotation is done as part of Transform in 3d nodes as 3d uses transform to do everything that postion and rotation accomplish in 2d,
https://docs.godotengine.org/en/stable/classes/class_transform.html#class-transform
hope this helps!

Hi, I'm pretty sure Spatial node have no equivilant property for modulate, Instead you would change the properties of materials applied to child meshes (hope that makes sense) rotation is done as part of Transform in 3d nodes as 3d uses transform to do everything that postion and rotation accomplish in 2d, https://docs.godotengine.org/en/stable/classes/class_transform.html#class-transform hope this helps!
Squatnet commented 2021-03-23 17:52:34 +00:00 (Migrated from github.com)

Labelled as wontfix, as the differences between 2d and 3d nodes are outside of this projects scope

Labelled as wontfix, as the differences between 2d and 3d nodes are outside of this projects scope
Squatnet commented 2021-03-28 18:13:14 +01:00 (Migrated from github.com)

@Zanark did you get this sorted? can i go ahead and close this issue?

@Zanark did you get this sorted? can i go ahead and close this issue?
Zanark commented 2021-03-28 18:22:03 +01:00 (Migrated from github.com)

Yes, thanks a ton for the help 😁

Yes, thanks a ton for the help 😁
Squatnet commented 2021-03-28 18:39:23 +01:00 (Migrated from github.com)

You are most welcome!

You are most welcome!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
squatnet/Godot-NodeJS-Websockets#1
No description provided.