Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | iamrifki |
I’m trying to make it so that in my code if the Node Modifier
gets its body entered, it will invert the variable numbers
extends RigidBody2D
export var speed = 250
var numbers = false
func _physics_process(delta):
position += transform.x * speed * delta
func _process(delta):
if numbers == false:
$Label.text = "%"
elif numbers == true:
$Label.text = "7"
func _on_Modifier_body_entered(body):
if body.is_in_group("shot"):
numbers = not numbers
print("SHOT")
print("NOT SHOT")
It seems like _on_Modifier_body_entered
doesn’t work at all as "NOT SHOT"
and "SHOT"
are never printed during testing.
No idea what’s happening, is there something wrong?
I closed the answer. to show as unanswered.
//////// Tried ///////
Get it right in “rigidbody properties”
from the inspector
contact_monitor = true
if it doesn’t work
////////////////////
try
func _on_Modifier_body_entered(body):
print(body)
pass
//////
The first one doesn’t work, and the second doesn’t print anything.
from the inspector
“Contacts Reported” to a value greater than 0.
////
Doesn’t work either, nothing is being printed.
///
Check that the signal is connected. The problem may be elsewhere.
ramazan | 2022-02-02 14:32
Seems connected
iamrifki | 2022-02-02 14:49
Also add a image of the “inspector” section.
ramazan | 2022-02-02 15:04
Here:
iamrifki | 2022-02-02 15:06
I think you’re using this as a bullet. Add a wall across, will there be a collision with “Staticbody”?
ramazan | 2022-02-02 15:22
I’m doing this as a “bullet”, yes, but that’s not the point. There won’t be a staticbody collision. All I want to do is to trigger a function that inverts (true
→ false
and vice-versa) a variable from a signal.
iamrifki | 2022-02-02 15:30