Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

geckoo

Moderators
  • Content Count

    2,824
  • Joined

  • Last visited

  • Days Won

    161

Everything posted by geckoo

  1. Maybe I can use rigidbody.velocity to define movement and animation? It's a good way?
  2. geckoo

    xibalba

    http://phoboslab.org/xibalba/ Tiny FPS doom-like ++
  3. geckoo

    Best games ever :)

    I forgot Bioshock the first and second episode ++
  4. using UnityEngine; using System.Collections; public class MovementUpdate : MonoBehaviour { private Vector3 lastPosition; private Quaternion lastRotation; private Transform myTransform; private float smooth = 5.0f; public GameObject oSpider; // Use this for initialization void Start () { if(networkView.isMine == true){ myTransform = transform; networkView.RPC("updateMovement", RPCMode.OthersBuffered, myTransform.position, myTransform.rotation); } else{ enabled = false; } } // Update is called once per frame void Update () { oSpider.animation.Play("Idle"); if(Vector3.Distance(myTransform.position, lastPosition) >= 2 || Quaternion.Angle(myTransform.rotation, lastRotation) >= 10){ lastPosition = myTransform.position; networkView.RPC("updateMovement", RPCMode.OthersBuffered, myTransform.position, myTransform.rotation); } } [RPC] void updateMovement (Vector3 newPosition, Quaternion newRotation){ if(!networkView.isMine) { transform.position = Vector3.Lerp(transform.position, newPosition, smooth * Time.deltaTime); transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, smooth * Time.deltaTime); lastPosition = newPosition; lastRotation = newRotation; oSpider.animation.Play("Run"); } } } Hi all. This script updates movements with smooth and plays an unique animation - run. I search a way to come back in first state - idle, when player does no movement. I can't understand why these entities always "run" also when they didn't move. I did a mistake somewhere. Thank you for your help.
  5. geckoo

    Line Renderer

    Maybe an example will be helpful? Create a simple GO and add this script to create a simple laser effect. You need to instantiate this GO and send start/end vector3. I use too a boolean when my Raycast hits a collider/tag... using UnityEngine; using System.Collections; public class SimpleLaserScript : MonoBehaviour { public bool hit = false; private LineRenderer lr; private float lrWidth = 0.065f; private Color col; public Vector3 start; public Vector3 end; // Use this for initialization void Start () { lr = GetComponent<LineRenderer>(); lr.SetPosition(0,start); lr.SetPosition(1,end); lr.SetColors(col,col); lr.SetWidth(lrWidth, lrWidth); if (hit) col = new Color(1,0,0,0.35f); if (!hit) col = new Color(1,0.5f,0,0.35f); } // Update is called once per frame void Update () { lr.SetColors(col,col); col.a -= Time.deltaTime * 0.5f; if (col.a<=0f){ Destroy(gameObject); } } } To instantiate this GO, you can do like this : (...) if (Physics.Raycast(originRay, out endRay, 100f)){ if (endRay.collider.gameObject.tag == "player"){ // hit a player hit = true; }else hit = false; (...) GameObject newLaser = (GameObject)GameObject.Instantiate(myGO); newLaser.GetComponent<SimpleLaserScript>().start = originRay; newLaser.GetComponent<SimpleLaserScript>().end = endRay; newLaser.GetComponent<SimpleLaserScript>().hit = hit;
  6. using UnityEngine; using System.Collections; /// <summary> /// This script is attached to the player prefabs and it hides /// the players own body so that it doesn't obstruct their camera. /// </summary> public class HideMyBody : MonoBehaviour { // Use this for initialization void Start () { if(networkView.isMine == false) { enabled = false; } Transform myBody = transform.FindChild("Soldier/Mesh"); myBody.renderer.enabled = false; enabled = false; } } Invert this code with your arms.
  7. It's what I need. I will create this sendRate value.Thank you for help ++
  8. using UnityEngine; using System.Collections; public class MovementUpdate : MonoBehaviour { private Vector3 lastPosition; private Quaternion lastRotation; private Transform myTransform; // false == Idle // true == Walk private bool anim; public GameObject oSpider; // Use this for initialization void Start () { if(networkView.isMine == true){ myTransform = transform; networkView.RPC("updateMovement", RPCMode.OthersBuffered, myTransform.position, myTransform.rotation, anim); } else{ enabled = false; } } // Update is called once per frame void Update () { anim = false; if(Vector3.Distance(myTransform.position, lastPosition) >= 0.05){ anim = true; // run lastPosition = myTransform.position; networkView.RPC("updateMovement", RPCMode.OthersBuffered, myTransform.position, myTransform.rotation, anim); } if(Quaternion.Angle(myTransform.rotation, lastRotation) >= 1){ lastRotation = myTransform.rotation; networkView.RPC("updateMovement", RPCMode.OthersBuffered, myTransform.position, myTransform.rotation, anim); } } [RPC] void updateMovement (Vector3 newPosition, Quaternion newRotation, bool anim){ transform.position = newPosition; transform.rotation = newRotation; oSpider.animation.wrapMode = WrapMode.Loop; if(anim == true)oSpider.animation.Play("Run"); else oSpider.animation.Play("Idle"); } } Hi friends. To update movement and animation for each player I modified this script which uses a boolean to define state of entity during game - two animations to start, idle and run (after I want define for each animation an integer). In fact, it works fine, but I asked myself about method. Before continue I wanna ask you about this tip. Personally I like this way because it seems to me very easy to create variation with many animations. It's just my point of view, but you are the masters. What do you think about this? It's efficient or not? Maybe I flood the bandwidth for nothing? Thank for your comments ++
  9. geckoo

    Music Water.

    Really cool effect. You are an artist ++
  10. Thank for this good share...
  11. Thank for the tips. Recently I bought the GTGD on steam for 1.49 euro. I think it's the best tutorial to understand all of NetWorking on Unity. Maybe it would be better to cut some videos because they are too long (sometime 2 hours), but it's a really good package. This is my point of view ++ http://store.steampowered.com/app/269570/
  12. Hi friends. I have some difficult to convert this code from M2H tutorial about NetWork. There is a persistent problem with array. I have find some explanation in the web, but I didn't understand all. I use this script in the MultiKit by TheMars2011. It work fine, but I can't accede to values because all source is in C#. I must convert this code. In fact, I got just one problem - chatEntries = new ArrayList()... Who can help me (us)? Thank you for your help ++ #pragma strict #pragma implicit #pragma downcast public static var usingChat : boolean = false; var skin : GUISkin; var showChat : boolean = false; //Private variable used by the script private var inputField : String= ""; private var scrollPosition : Vector2; private var width : int = 400; private var height : int = 180; private var playerName : String; private var lastUnfocus : float = 0; private var window : Rect; private var chatEntries = new ArrayList(); class FPSChatEntry { var name : String = ""; var text : String = ""; } function Awake() { playerName = PlayerPrefs.GetString("playerName", playerName); usingChat = false; window = Rect(5, 5, width, height); } function CloseChatWindow () { showChat = false; inputField = ""; chatEntries = new ArrayList(); } function ShowChatWindow () { showChat = true; inputField = ""; chatEntries = new ArrayList(); } function OnGUI () { if(!showChat){ return; } GUI.skin = skin; if (Event.current.type == EventType.keyDown && Event.current.character == "\n" && inputField.Length <= 0) { if(lastUnfocus + 0.25 < Time.time){ usingChat = true; GUI.FocusWindow(5); GUI.FocusControl("Chat input field"); } } window = GUI.Window (2, window, GlobalChatWindow, ""); } function GlobalChatWindow (id : int) { for (var entry : FPSChatEntry in chatEntries) { GUILayout.BeginHorizontal(); if(entry.name == ""){//Game message GUILayout.Label (entry.text); }else{ GUILayout.Label (entry.name + ": " + entry.text); } GUILayout.EndHorizontal(); } if (Event.current.type == EventType.keyDown && Event.current.character == "\n" && inputField.Length > 0) { HitEnter(inputField); usingChat = false; GUI.UnfocusWindow ();//Deselect chat } GUI.SetNextControlName("Chat input field"); inputField = GUILayout.TextField(inputField); } function HitEnter(msg : String){ msg = msg.Replace("\\n", " "); networkView.RPC("ApplyGlobalChatText", RPCMode.All, playerName, msg); inputField = ""; //Clear line GUI.UnfocusWindow ();//Deselect chat lastUnfocus = Time.time; GUI.FocusControl(""); //Close chat usingChat = false; } @RPC function ApplyGlobalChatText (name : String, msg : String) { var entry : FPSChatEntry = new FPSChatEntry(); entry.name = name; entry.text = msg; chatEntries.Add(entry); //Remove old entries if (chatEntries.Count > 5){ chatEntries.RemoveAt(0); } } //Add game messages function addGameChatMessage(str : String){ ApplyGlobalChatText("", str); if(Network.connections.length > 0){ networkView.RPC("ApplyGlobalChatText", RPCMode.Others, "", str); } }
  13. public Transform bulletGo; //... Vector3 direction = gameObject.transform.TransformDirection(new Vector3(Random.Range(-0.01f, 0.01f) * spread, Random.Range(-0.01f, 0.01f) * spread, 1)); RaycastHit hit; if (Physics.Raycast(bulletGo.position, direction, out hit, range, hitLayers)){ // bla bla Use Random.Range with your RayCast to create a spread ++
  14. I saw http://armedunity.com/topic/9106-unity-master-server-alternative/#entry80036
  15. Hi folks! It seems to me Unity master server (again) is out today. I read in the M2H tutorial about NetWorking that we can create and set up an own master server. Source available on RakNet site, and for many platforms. Maybe somebody did this tool or uses another alternative? I don't know how we can configure Unity for connect with a second master server. There is a panel somewhere? This problem is really annoying ++
  16. Hum... I tried all versions of this game and It works fine every time without lags. Do you have some errors during game - some explanation? Whats is your Unity version?
  17. geckoo

    Watch here

    In fact, you want a full game if I understand
  18. I found a bug in the 1.51 version of the game. When a player appears in the game after prime connection with the server, it remains suspended in the air. Until the first movement/refresh, it not was in contact with the ground. I have pressed a key and all is perfect. I think we must disable render before first movement. It's just an idea ++
  19. I have never played with a slender game. Maybe soon ++
  20. geckoo

    Best games ever :)

    1-FPS (Black Ops - the first, during cold war and BF3) - Multi (BF3, Day of Deafet or TF2) 2-Strategy Games (rts) - nothing. I hate this. 3-MMORPG - nothing 3- 3rd Person shooter - SpecOp the Line 4- card games - WTF
  21. Yeah. I think too. There's something very different with this weapon, but all weapons are patented. No? Except AK47 maybe...
  22. I see a problem with the french MG FAMAS which is in all modern FPS. It's a summary for "fusil d'assaut de la manufacture de Saint-Etienne". You use the name - you use the brand ++
  23. geckoo

    Mehanium

    it didn't work - never
  24. Strange. It seems to me, TheMars2011 uses a pro version Unity ++
×
×
  • Create New...