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.

jordanblythe104

Premium Member
  • Content Count

    210
  • Joined

  • Last visited

  • Days Won

    1

jordanblythe104 last won the day on June 18 2014

jordanblythe104 had the most liked content!

Community Reputation

35 Excellent

1 Follower

About jordanblythe104

  • Rank
    Premium
  • Birthday 02/23/1994

Contact Methods

Profile Information

  • Gender
    Not Telling
  • Location:
    Australia
  • Interests
    Long walks on the beach

Recent Profile Visitors

675 profile views
  1. Updated with a download link, let me know if there's any problems.
  2. It's a showcase but I could upload it and edit in the download link here I guess.
  3. Very happy with how these turned out, here's the download link: https://docs.google.com/uc?id=0B6Kq-NGP6BvGVkFEV3RiSG5pM1k&export=download
  4. Looking great, will be monitoring this thread for sure.
  5. GameObject FindClosestEnemy() { GameObject[] gos; gos = GameObject.FindGameObjectsWithTag("Enemy"); GameObject closest = null; float distance = Mathf.Infinity; Vector3 position = transform.position; foreach (GameObject go in gos) { Vector3 diff = go.transform.position - position; float curDistance = diff.sqrMagnitude; if (curDistance < distance) { closest = go; distance = curDistance; } } return closest; } } Just found this in the unity script reference in case anyone else runs into this problem.
  6. I just need to know how to have a function return me a Transform or GameObject, the code is giving me errors because it's wrong for many reasons. In Unityscript, I can write the following code if I want the function to give me the specified type. Just wondering how or if it can be done in C#. function FindClosestTarget(): GameObject{ return (GameObject); }
  7. jordanblythe104

    C# issue

    Recently switched from unityscript to C# and I've really enjoyed it so far. I have run into a problem however when trying to convert an old unityscript function to C#. Unityscript version works fine, returns me the closest visible object I'm looking for. function FindClosestTarget(): GameObject{ var closest : GameObject; var distance = Mathf.Infinity; var position = transform.position; var targets : GameObject[]; if(faction == Faction.blue){ targets = GameObject.FindGameObjectsWithTag("TeamRed"); } if(faction == Faction.red){ targets = GameObject.FindGameObjectsWithTag("TeamBlue"); } var uVect = Vector3(0, 0.4, 0); // Iterate through them and find the closest visible one for (var i = 0; i < targets.length; i++) { var hit : RaycastHit; if(Physics.Linecast(sightTransform.position, targets[i].transform.position + uVect, hit)){ if(faction == Faction.blue){ if(hit.transform.root.tag == "TeamRed"){ var diff = (targets[i].transform.position - position); var curDistance = diff.sqrMagnitude; if(curDistance < distance){ closest = targets[i]; distance = curDistance; } } } if(faction == Faction.red){ if(hit.transform.root.tag == "TeamBlue"){ var diff2 = (targets[i].transform.position - position); var curDistance2 = diff2.sqrMagnitude; if(curDistance2 < distance){ closest = targets[i]; distance = curDistance2; } } } } } return closest; } C# version has a bunch of errors and I don't really know how to fix them, I'm also searching for a Transform rather than a GameObject. Transform FindClosestTarget() { Transform Closest; float Distance = Mathf.Infinity; Vector3 Position = transform.position; GameObject[] Targets; if(faction == Faction.Blufor) { Targets = GameObject.FindGameObjectsWithTag("Opfor"); } if (faction == Faction.Opfor) { Targets = GameObject.FindGameObjectsWithTag("Blufor"); } for (int i = 0; i < Targets.Length; i++) { RaycastHit hit; if(Physics.Linecast(Sight.position, Targets[i].transform.position, hit)) { if (faction == Faction.Blufor) { if (hit.transform.root.tag == "Opfor") { float diff = (Targets[i].transform.position - Position); float curDistance = diff.sqrMagnitude; if (curDistance < Distance) { Closest = Targets[i].transform; Distance = curDistance; } } } if (faction == Faction.Opfor) { if (hit.transform.root.tag == "Blufor") { float diff2 = (Targets[i].transform.position - Position); float curDistance2 = diff2.sqrMagnitude; if (curDistance2 < Distance) { Closest = Targets[i].transform; Distance = curDistance2; } } } } } return Closest; }
  8. I really like visual studio, switched to it from sublime text 3 and I've really enjoyed it so far. It's a little over-zealous with its formatting which can get annoying but other than that it's been really nice to work with. I really like that the script reference is integrated.
  9. I'm getting some weird issues with exporting fbx with animations from blender to unity and I can't figure out why. I have the latest version of both unity and blender, I am using all the correct settings as far as I know and I'm still having issues. This picture is how it looks in blender: And here's what happens in Unity: Here are my export settings: Any ideas? This is really frustrating, I really don't want to have to re-rig and animate again.
  10. Yeah I just got that, thank you for being patient with me. Really appreciate the help
  11. Still this Error log: "Cannot convert 'UnityEngine.GameObject[]' to 'System.Collections.Generic.List.<UnityEngine.GameObject>'." Edit - It was on a new line, doh
  12. I think I can work around it by making targets a local variable and recreate it whenever I need it.
  13. Just corrected that in all of my code and still getting the same error. Maybe game objects in a list are treated differently to actual game objects? It's a shame there's so little documentation on such an important issue like this.
  14. if(targets.length > 0){ for(var i = 0; i < targets.length; i++){ var hit : RaycastHit; var uVector = Vector3(0, 0.6, 0); if(Physics.Linecast(sightTransform.position, targets[i].transform.position + uVector, hit)){ if(faction == Faction.blue){ if(hit.transform.root.tag == "TeamRed"){ state = 1; } } if(faction == Faction.red){ if(hit.transform.root.tag == "TeamBlue"){ state = 1; } } } } } Error log: "Cannot convert 'UnityEngine.GameObject[]' to 'System.Collections.Generic.List.<UnityEngine.GameObject>'."
×
×
  • Create New...