Improbable Icon

Click on object

I’m wondering how do you handle clicking on objects.
For example there is a MediPack but I don’t ran into it, instead I’m clicking it using my mouse and collect it.

How should I handle this situation?
Should I send command with the entity ID?

Or should I send command with the camera rotation, mouse position and generate the raycast on the server side?

Or is there any other solution for this?

Have you any examples of mouse clicking on the entites?

Hi @Wader , here’s how I would tackle the problem.

- raycast to object, get entity information
- send a PickUpItem command request (could live on the player inventory component or object 'pickupable' component)
- (optional) CSP/animation/inventory

- do any validation you'd want (e.g. raycast from player to check if obstructed, range check to player, etc.)
- (if valid) update player inventory
    - (optional) update third-party inventory database
- respond to command (success/failure)

Client (success):
- (optional) provide feedback (visual/audio)

Client (failure):
- (optional) provide feedback (visual/audio)
- (optional) roll back any CSP

The benefits of this approach versus sending the camera and mouse information is that the bandwidth will be lower, and that you can also still verify that the player is able to pick up the item using some simple checks.

There’s nothing to stop a client sending falsified camera and mouse position data, which you’d have no way to verify.

This is my personal take though and may not meet all needs down the line.