Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Gamingdrake · Jun 16, 2013 at 04:04 AM · physicsraycast

Is Physics.Raycast deterministic?

I am currently constructing a multiplayer RTS. I know that the transform math done on an object is not deterministic, so I am caching an integer based version of each units transform and doing the math on that, and then converting it back at the end of the update cycle. Therefore, I have two main questions that pertain to this.

Will this system work, if I do all my distance checks and movement functions with the cached transform?

If I use Physics.Raycast with this cached transform, can I get a reliable outcome? Is Physics.Raycast deterministic without this cached value, and if not, how do I go about raycasting without Physics.raycast?

Thank you for your help, and I am sorry if this is a noobish question. I have looked all over as to how to best implement RTS networking in Unity, and so far, this is as close as I can get.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Jun 16, 2013 at 06:18 AM 2
Share

The simple answer to your question is no.

It now transpires you're already making the "most sophisticated" type of client-server game and you're already highly familiar with doing this.

It's confusing why you'd need to get "deter$$anonymous$$istic" (I guess you mean the same floats) results in the client in that schema because you don't - say - "check the work" in that approach (or it defeats the whole purpose of limited independent thinking on clients). But in any event that's irrelevant, the answer to your question is simply "No" -- enjoy!


For any beginners reading....

It's not a noobish question, it's a great question.

However ... I have very bad news. I expect you are going about the game totally incorrectly.

$$anonymous$$ultiplayer games are done like this:

one iPad is the "game boss". the other iPads are the "game clients"

EVERYTHING is actually done on the "game boss". All physics, movement, everything.

The rest -- are simply puppets. They do nothing. They just display everything, as told to by the game boss.

What you appear to be trying to do will never, ever work I'm afraid.

I suggest, step back and learn / readup on basic $$anonymous$$P techniques .. you'll be a real video game engineer ASAP! :)

Please note that this question comes up from time to time

http://answers.unity3d.com/questions/412765/multiplayer-multi-agent-and-bullet-question.html

Please up vote my helpful answers there as I need moar points :) Cheers

{Further note -- in some types of games, notably racing vehicle games .. the situation is incredibly complicated. The puppets make predictions about let's say "inter-report" motion and events, and they do their best to align themselves with what the gameBoss is saying, including ridiculously complicated decisions about what to do if it makes the "wrong guess" or whatever. FWIW you can find some advanced discussion on here about such issues. For example, notice the very generous answer here by Whydoidoit .. http://answers.unity3d.com/questions/329457/few-questions-regarding-multiplayer.html Please upvote his valuable answer there as he too needs moar points :) }

{Note .. I use the term "game boss". you could call it a "server" but this is confusing because it makes you think of the "other type" of servers, ie, the player matching server, or if you are doing a $$anonymous$$$$anonymous$$PG the remote server that runs the actual game play. So I just say "game boss" to describe the lead iPad .. you know when it says "host a game or join a game!" essentially. There are many long discussions on here about nothing other than this nomenclature.}

Sorry for the generally bad news !

avatar image Fattie · Jun 16, 2013 at 07:01 AM 0
Share

"The client server architecture works as a general case for most games."

Well, I guess that's true yeah! :)

"However, because its an RTS, I cannot have one client act as a server and send all of the unit data to each client."

So the number is about 1000 ? Shouldn't be an issue. You're talking in a very advanced manner, so you're clearly already experienced on $$anonymous$$ms doing $$anonymous$$P games of all description .. so that won't be an issue in Unity assu$$anonymous$$g you have good update strategies.

"a pseudo client server architecture..." well yes, that's what I alluded to in my first bracket "Further note ..."

"Finally, if I had a server .. etc" well not really, many games you play every day use -- locally, on the iPads or Pcs -the type of architecture we;re describing. Other games (Doom or whatever) have the thinking on an internet server.

avatar image Gamingdrake · Jun 16, 2013 at 07:18 AM 0
Share

Since its an RTS, sending ~1000 unit states across the network to every client every "network update" is unfeasible if I want them to run anywhere near 30fps. $$anonymous$$any current RTS games use a lock step architecture developed by the developers on AOE, so I was thinking about replicating that technique. However, I can do other architectures and as long as I build it correctly it should run.

The client-server architecture has syncing issues that can be dealt with if a few units are synced every frame. That will guarantee that the units are consistent across machines. However, it still goes back to my main issue of whether or not the raycast is deter$$anonymous$$istic. Floating point calculations are not guaranteed to be consistent between machines or even between instances. Therefore, I need to take that into consideration when I build the architecture that is supposed to handle de-synchronizations between clients caused by floating point errors.

avatar image Fattie · Jun 16, 2013 at 02:05 PM 0
Share

Well the good news is, as it says at the top of my answer, "The simple answer to your question is no."

once again -- the answer is no

Just as a curiosity I don't really see how it's relevant because there's no conceivable predictive $$anonymous$$P strategy where you are "relying on" two outcomes to be the same. It's possible that, just here in Unity or something, you are looking at it in a let's say Unity-unusual way that essentially makes my response "yeah it's a float so they won't be the same but it sounds odd you are looking fro them to be the same."

"1000 unit states .. is unfeasible" you may be surprised how much data you can pump. it goes without saying you would be using various strategies (which obviously you would be familiar with based on your expert knowledge) and you often have to send remarkably little actual bits, it's surprising how it works out

"Floating point calculations are not guaranteed to be consistent between machines or even between instances"

Well yes, you've answered your own question! So that's good news.

"Therefore, I need to take that into consideration when I build the architecture that is supposed to handle de-synchronizations between clients caused by floating point errors."

I guess I would say, every single thing - every time, every unit, every frame, every concept - is going to be "desynchronized" and predictive RT $$anonymous$$P strategies involve, are all about, their raison d'etre is, to make the game still look O$$anonymous$$ and work logically, even though (the best way I have heard it expressed) everything is a smear.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Physics.Raycast (Cheapest Methods) 0 Answers

Creating a magnetic vehicle (like F-Zero) 1 Answer

Physics.IgnoreRaycastLayer putting GameObject on layer 4 water. 0 Answers

Slant Physics Raycast Implementation 0 Answers

How Accurate is Unity Physics? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges