I think this is specifically a logic question in JS, I’m coming from OOP languages and I need help understanding how to handle events when raycastring / interacting with objects. Looking at all the examples of raycasting they are just changing the transforms of the object and don’t offer a solution to my question.
if (hit.pickedMesh){
hit.originMesh.scaling.y += 0.01;
}
How do I fire off an event if a player was to raycast something and press E (say open a door) do I get a component on the door then hit.object.OpenDoor()
? Or get the doors hit.name
and preform some logic with the object name if(hit.name == "door1)OpenDoor()
? This example can be used for all my questions (picking up objects in inventory, triggering events: timers, quick time events).