Skip to content

Conversation

vontell
Copy link

@vontell vontell commented Mar 14, 2024

Video demonstration: https://www.loom.com/share/408d1d185704492ca24fc4206445a6e6?sid=5c105e98-c980-4e9f-80b7-ef7c55047b38

Hey Spatial team! We finished up the initial bot discussed last week, and it’s working great! As you’ll see in the video, the bot is configured to move randomly during a random interval of time, keep a minimum distance from other players/bots, miss the ball with a certain probability, and target the nearest player with a certain probability. All of these configs are adjustable via a config pane in the editor.

The only roadblock we encountered here was that the logic for which player to target existed in the BallControl.cs file, rather than the Bot.cs file. Ideally, all bot logic would exist in the bot file, but if the ball and bot are not owned by the same client, it was unclear how to have a bot alert or tell the ball which player to target. Is there a “messaging” system that allows synced objects to communicate? TLDR; the original code treats the ball almost as its own character that decides who to target, but it may be beneficial to have the bots decide that for themselves? If not, we can leave it as is and have target selection not be part of the bot logic.

}

private bool TryFindNewTarget(bool resetVelocity)
private bool TryFindNewTarget(bool resetVelocity, bool targetClosest = false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deterministically choosing what player the Bot/Ball Targets

Theres a few ways you could go about this,

  1. Currently the owner of the ball is fully in control of it for the whole game. When a bot blocks a ball it could takeover ownership of the ball and dictate the new target from there.

This was actually my original plan. Each time the ball targets you or a local bot, you takeover the ball so that you sim it locally. Remove any network lag etc, but I felt it made the code a little messy and obviously vulnerable so for now we have single ownership on the ball.

  1. A bot could pre-decide if it will block and who it will target and sync this state. Then when the ball hits the bot the master-client it will read the state and make it happen.
  2. You can message between networked clients with RPCs using our networking service.

2 is probably this simplest to add to the current code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alan! I'll think about this and see what changes can be made 👍

Copy link
Contributor

@AlanSpatial AlanSpatial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything here looks really good 👌 🔥

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

Successfully merging this pull request may close these issues.

3 participants