Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Changing object collision_enabled and visible doesn't seem to work #217

Open
pietru2004 opened this issue Jun 20, 2024 · 6 comments
Open
Labels

Comments

@pietru2004
Copy link

Which environment? Mirror Official app (Itch/Steam/Epic), open-source docker, or open-source no-docker?
Itch

When I used code

        target_object.collision_enabled=true/false
        target_object.visible=true/false

(Note: / is OR)
It didn't work in dev mode
I went and used target_object.model_scale it worked in dev, when I published space(link below) changing model scale didn't work.
Also in dev env I noticed ghost collisions for object that has model_scale modified via code and I was unable to tween it, if I did all I seen was state 0 and 1 I mean when wanting object to have scale changed from Vector3(0,0,0) to Vector3(1,1,1) All I could see was object visible or invisible, also I think object scale was tweened properly, although I am not sure on that one.

If I am not mistaken it has been like that since release of adding gdscript scripts to objects...

Additional context
https://in.themirror.space/s/66473a3371ccefbdaae05f66

@pietru2004 pietru2004 added the bug label Jun 20, 2024
@pietru2004 pietru2004 changed the title [Bug] Changing object collision_enabled and visible doesn't seam to work both in build and play modes [Bug] Changing object collision_enabled and visible doesn't seam to work Jun 20, 2024
@RevoluPowered RevoluPowered changed the title [Bug] Changing object collision_enabled and visible doesn't seam to work [Bug] Changing object collision_enabled and visible doesn't seem to work Jun 21, 2024
@krnico
Copy link

krnico commented Jun 22, 2024

maybe this does not work beacause you are executing this server side only?, have you tried runing the gdscript code in the client aswell? the only way to execute gdscript code on the client at the moment is by compiling a custom Mirror client using the custom godot build and edit client to run it.

@RevoluPowered
Copy link
Collaborator

Recommendations for the mirror to implement/fix this issue:

  • We need to add an API method for setting non-networked properties, like this.

For the person fixing this (or networked methods basically)

  • target_object.model_scale should be implemented as target_object.set_scale()
  • target_object.visible should be implemented as target_object.set_visibilty()

Furthermore we need to fix the difference here between play and build.

@krnico
Copy link

krnico commented Jul 13, 2024

There is a wayarround this by using this line of gd script for setting collision or visible to false/true:
Zone.script_network_sync.set_property_on_node(space_object, "collision_enabled", false)
or
Zone.script_network_sync.set_property_on_node(space_object, "visible", false)
this should work properly using singleton with Mirror.set_object_property() function in the future.

@krnico
Copy link

krnico commented Jul 13, 2024

So i found the bug on Mirrors singleton set_object_property function:

static func set_object_property(property_object: Object, property_name: StringName, property_value: Variant) -> void:
	property_object.set(property_name, property_value)

this only works locally
to fix this should be:

		# This will also set it locally immediately.
		Zone.script_network_sync.set_property_on_node(property_name, property_name, property_value)

@krnico
Copy link

krnico commented Jul 13, 2024

Also for tween model scale you want to use Mirrors singleton's tween_object_property function
this does work properly and hasn't the same bug
Alternatively you can use:
Zone.script_network_sync.tween_property_on_node(property_object, property_name, to_value, duration, trans, easing)

@krnico
Copy link

krnico commented Jul 22, 2024

if after apply
target_object.collision_enabled=true/false
you apply this:
target_object.queue_update_network_object()
it works!
you need to sync object with clients

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants