Tag Info

Hot answers tagged

4

Your code is very scrambled. You have all your time relative variables inside the shooting loop. and the instantiation code too. Why? Why not simply make it like this : void ShootBullet() { Rigidbody bPrefab = Instantiate (bulletPrefab, transform.Find ("Bullet").position, Quaternion.identity) as Rigidbody; bPrefab.AddForce (transform.up * ...


2

In the frame that bulletCounter become 3, Time.time will be less than gunGlobalCooldown because this line of code: gunLocalCooldown = Time.time + 0.12f; gunGlobalCooldown = gunLocalCooldown + 0.8f; so the boolean canShoot will be set to false, and this if if (Input.GetKey (KeyCode.Space) && Time.time >= gunLocalCooldown && ...


2

I had to solve this issue a long time ago, and all I did was do: One normal collision check. One where I shifted everything up one "world-height" (aka screen height) Shift down Shift left one "world-width" (screen width) Shift right Up and Right Up and Left Down and Right Down and Left eg: if(x + width > test.x && x < test.x + test.width ...


2

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++) { if (s1[i] != s2[i]) { Debug.Log ("The " + i.ToString() + "th character is different."); return false; { } return ...


1

Edit: After posting this I realized it's almost the exact same answer given by Ali.S (slightly different but the overall approach is the same.) It started out as something completely different though. This method assumes that all communications are being held over a series of secure tunnels. How you achieve this doesn't matter. I would suggest TLS, but ...


1

There are multiple solutions that I can think of, but here is the most secure one: client connect to server. client requests an authentication bridge. server connects to auth server, acting as a proxy between player and auth. server. client and auth server, form an SSL session over this newly formed bridge. using this secure connection over bridge, client ...


1

The client should have a private and a public key. The private key should be what the unique identifier that the client receives from the authentication server. The public key should be also sent to the client. Before the client connects to a game server, it should send a message with its private key and the ip of the game server it wants to connect to, ...


1

Coroutines are the best performance-wise. I.e. void Start () { //Starting the coroutine StartCoroutine (Shooter()); } IEnumerator Shooter () { if (Input.GetMouseButton(0)) { //Shoots the bullet Rigidbody bullet = Instantiate (Bullet).GetComponent<Rigidbody>; bullet.AddForce (Camera.main.transform.forward * 10, ...


1

So this doesn't produce exactly the behavior you asked for but I think it might be what you're looking for anyway. This code (syntax not exact as I don't use c#) would allow someone to sustain a fire rate of one bullet per 0.5 seconds indefinitely, but fire bursts of up to 3 bullets at a rate of one bullet per 0.12 seconds. gunBurst=0.12f gunSustained=0.5f ...



Only top voted, non community-wiki answers of a minimum length are eligible