Hi, is there any way how to sync for another spectators trrigered animation? If I will clickk on theee object with animator and run animation? I made it only with drag scriped attached to this object, but it is only one way. I am looking for both ways solution. I know this is because drag script make me as master. But Ii need to send animation to all spectators on click.
Original Post on Discord
by user 869976161550217286
better said, how to send command that forr every spectator will be trigered animator, is that possible?
by user 869976161550217286
for example open door
by user 869976161550217286
marcel
(marwi)
June 13, 2023, 12:00am
4
You can send an event via the networking backend to all clients when you trigger the animation (and which animation you triggered)
And then listen to that event and set the trigger on the animator.
Using this.context.connection.beginListen
and this.context.connection.send
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally. Needle Exporter for Unity bridges the Unity Editor and the...
Thank you, but I am not coder, but if there eis some simple example of code? I can try to modify it. I assume its some script atted to scene. key:string is name of animation? I am verry sorry, but I am trying to learn TypeScrypt, but there is manyβ¦
by user 869976161550217286
Or some script attached on object with animatiton? I was reading documentation, but I dont know where to start
by user 869976161550217286
here is the scene. I need to show opening of the doors and windows to spectators. Svojanov_update_2023
by user 869976161550217286
And same solution for show hide object? I am using SetActiveOnClick script.
by user 869976161550217286
marcel
(marwi)
June 13, 2023, 12:00am
9
Add this script:
import { Behaviour, EventList, IPointerClickHandler, PointerEventData, serializable } from "@needle-tools/engine";
export class SyncedClick extends Behaviour implements IPointerClickHandler {
@serializable(EventList)
onClick!: EventList;
onPointerClick(_args: PointerEventData) {
console.log("SEND CLICK");
this.context.connection.send("clicked/" + this.guid);
this.onClick?.invoke();
}
onEnable(): void {
this.context.connection.beginListen("clicked/" + this.guid, this.onRemoteClick);
}
onDisable(): void {
this.context.connection.stopListen("clicked/" + this.guid, this.onRemoteClick);
}
onRemoteClick = () => {
console.log("RECEIVED CLICK");
this.onClick?.invoke();
}
}
on your door for example and then set the trigger via the Unity event
it will be similar solution?
by user 869976161550217286
marcel
(marwi)
June 13, 2023, 12:00am
11
Make sure to also add the ObjectRaycaster (or you should have an ObjectRaycaster in your parent hierarchy)
Wow, thats great, I will trry and inspect
by user 869976161550217286
marcel
(marwi)
June 13, 2023, 12:00am
13
You dont need the collider btw
This script send position of mouse cursorr and click event to otherrs? That means also Set aSetActive On Click script will work?
by user 869976161550217286
marcel
(marwi)
June 13, 2023, 12:00am
15
You can just plug any function into the unity event and it will be synced when you click the object this script is on
Yes confirmed, it works, and is universal
by user 869976161550217286