Hello everyone. I'm sorry for my english and for my silly question. I still don't know much. Please, help me.
I want tocreate a simple interaction between my character and different objects. I have some bug in "interactedObjects.gd" script, and i don't know how can i fix it.
I have character with nodes:
PlayerBody - Movable character
PlayerCollision - Character collision "PlayerCollision" is disabled on the start. (Disabled - On)
InteractedObjects - Object for interact.
IntTree1 - Collision for "InteractedObjects "
Apple - Sprite witn Apple picture
Player have to clicked on the interactoble object is tree -
func _on_InteractedObjects_input_event(viewport, event, shape_idx):
After that the node is ("PlayerBody/PlayerColision") become enabled.
if event is InputEventMouseButton:
get_parent().get_node("PlayerBody/PlayerColision").disabled = false
("PlayerCollision" is disabled on the start. (Disabled - On))
Character will start move to the tree, and after intersect collision shape (IntTree1 ), Apple is disappear -
func _on_InteractedObjects_body_entered(body):
get_parent().get_node("Apple").visible = false
Then, if character leaves the area, apple become visible and player collision become disabled.
func _on_InteractedObjects_body_exited(body):
get_parent().get_node("Apple").visible = true
get_parent().get_node("PlayerBody/PlayerColision").disabled = true
Well, when the game start, and my character runs over the tree's colision, apple is visible, which is right, because i didn't click on the tree. When i clicked on the tree, my code is work, but when my character leaved from tree's collision shape, the collision shape of the character is still active, however it have to disamled. And when my character uns over the tree's colision again, the apple becomes invisible without clicking on the tree, which is not right.
Please tell me how to fix the error, give a link to the lesson or just give advice on how to fix it.
Project is in archive - Judge_Test_2.rar (Use URL)
https://drive.google.com/file/d/1T-lakDFB4lc_oKLahdYUsJMi7Ebp7v6n/view?usp=sharing
