On stage editor I have an Area2D with this code:
extends Area2D
const PlayerController = preload("res://player/script/2017-07-25/PlayerController.gd")
func _ready():
connect("body_enter", self, "_on_player_body_enter")
pass
func _on_player_body_enter( body ):
if body.get_name() == "Player":
print(PlayerController.CollisionState.has("Bottom"))
print(PlayerController.CollisionState)
print(get_tree().get_root().get_node("Game").get_node("Player").CollisionState)
if PlayerController.CollisionState.has("Bottom"):
PlayerController.CollisionState.Bottom = true
# get_tree().get_root().get_node("Game").get_node("Player").CollisionState.Bottom = true
If the Player enter in to the Area2D, the value of CollisionState.Bottom have to be true, where CollisionState is an enum on PlayerController:
extends KinematicBody2D
enum CollisionState {
None,
Top,
Right,
Bottom,
Left,
Wall,
Slope,
RSlope,
LSlope
}
var groundRayCasts = []
var onAir = false
func _ready():
CollisionState.None = true
CollisionState.Top = false
CollisionState.Right = false
CollisionState.Bottom = false
CollisionState.Left = false
CollisionState.Slope = false
CollisionState.RSlope = false
CollisionState.LSlope = false
CollisionState.Wall = false
...
... More code here ...
But the Debugger show this error:
Invalid set index 'CollisionState' (on base: 'GDScript').
But the prints show this:
True
(Bottom:True), (LSlope:False), (Left:False), (None:True), (RSlope:False), (Right:False), (Slope:False), (Top:False), (Wall:False), (lSlope:False)
(Bottom:True), (LSlope:False), (Left:False), (None:True), (RSlope:False), (Right:False), (Slope:False), (Top:False), (Wall:False), (lSlope:False)
What I'm doing wrong?