JPtheK9
• Member for 7 years
• Last seen more than a month ago
• New Mexico

It's actually the other way around. Games are made deterministic to be online. The basic idea is to send commands rather than game state. If you have a function F(X) = Y and you need everyone's Y to ...

Alternatively, you could use System.Timers.Timer which is probably the most performant of any solution. The following example shows a countdown for 100 seconds. System.Timers.Timer LeTimer; int ...

According to the answers on this page, about 512 is a safe amount for ipv4 because nearly all consumer's hardware will be able to support that size. For ipv6, 1500B is the maximum safe packet size. ...

Many infinite runners scroll the road rather than move the player forwards on the road to make the road truly infinite. You can do this with 2 alternating game objects. public GameObject[] RoadPieces ...

Yes, you can do this with no expensive trig at all. Steps: Find the distance between the 2 circles. Find the combined radius between the 2 circles. Subtract the distance from the combined radius to ...

You've got the moving part right but the rotating adds a significant amount of complexity to the problem. Luckily, you can hack in rotational velocity with a formula mentioned here. It approximates ...

If you're really hardcore and want to take the extra optimization, a static object pooler will be the best choice performance-wise. Most of the time, an instance object pooler will work perfectly. It ...

LocationInfo is a struct so you need an instance of it to access its members. You can find a populated instance under (LocationService.lastData)[http://docs.unity3d.com/ScriptReference/LocationService-...

You should do a bounds check as you mentioned then reduce the velocity so you don't get shaky behavior. You kind of got it but I'm not sure what displacement does. //This code goes after velocity is ...

If you're using a grid, you shouldn't be using Unity's physics for collision detection - use the grid. Get your position on the grid then do something like this: public bool GridCast (Coordinate ...

If you want to be hardcore about it... public static bool StringComparison (string s1, string s2) { if (s1.Length != s2.Length) return false; for (int i = 0; i < s1.Length; i++) { ...

Here's a function that interpolates between Start and End quadratically by T. float Qerp (float Start, float End, T) { //The quadratic stuff T = 1 - T; T = 1 - (T * T); float ...

Maps, items, monsters, etc. gives you many factors that can be tipped out of balance by 1 small difference in a floating point operation. A character moves a little bit more to the right, he bumps ...

Box cast would probably be more performant since it's only checking 4 vertices but it'll definitely be more accurate, at least depending on what you want. Good idea! Example use: RaycastHit2D ...

PlayerPrefs are not designed for saving scores. They are easily modifiable by the end user in a text file. Instead, you should serialize settings, replays, etc. that players have no motivation to hack....

Without a doubt, an executable per map would be the best option because servers run collisions detection. Collision detection increases in complexity by O(N) so a single instance with 500 objects will ...

This is fun! The trajectory is just a bunch of mathfz and a line renderer. Check out this post for more information on that which details how to calculate the trajectory. Line renderers are definitely ...

Detect collisions with OnCollisionEnter then load your level there. I.e.: void OnCollisionEnter (Collision col) { Application.LoadLevel("Level1"); } If your character's Collider is a trigger, ...

If you're using, for example, Unity's standard networking without an authoritative server, an RPC would be better because syncing something every frame can be VERY expensive because the packet header ...

Unity's collision detection is discrete so if an object passes through another object within 1 simulation frame, the collision will not be detected. If the collision is already detected, however, ...

The key to large-scale synchronization is determinism. Basically, if you can plug X into a function and get the same Y on all computers, you can send X instead of Y. For example the de facto RTS game ...

I found the answer thanks to this essay Daniel posted. It's something like this (from page 10): closing_distance = max_speed * 2; desired_velocity = normalize (position - target) * max_speed if (...

You could make a bool that, if true, checks for all input. If false, you essentially turn off all input. bool DoInputs = true; IEnumerator Dash() { if (DoInputs) if (player.GetAxis("...

I ran into the same problem today and made a pretty big mountain of spaghetti out of a mole hill but ended up with something that works: https://github.com/SnpM/Pan-Line-Algorithm. From the ReadMe: ...

Reverted to UnityEngine.Animation. Works like a charm and has no performance hits.

For 200+ moving objects, you're definitely going to want to make your game lockstep. With lockstep, comes the need for determinism but that shouldn't be too hard for bacteria (which can be simulated ...

Use an influence map for target searching. Have a grid and on each node, reserve a spot in a collection of units for each team. For each unit, generate a collection of coordinates within range and ...

using UnityEngine; using UnityEngine.UI; public class SliderSaver : MonoBehaviour { public Slider slider; void Awake () { slider.Value = PlayerPrefs.GetFloat ("Slider value"); ...