Search Unity

3D Radar UI : Beta-2d July-22-2016

Discussion in 'Assets and Asset Store' started by ForceX, Feb 23, 2011.

  1. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Well I've been trying to update the _GameMgr with no luck so far. I have a feeling I shall have to abandon the idea of using this radar on my project as being multiplayer, the radar isn't going to play ball. Even though I haven't managed to get it to update, I think that it is going to break with more than 1 player on the network. If I manage to update the _GameMgr with my player ship, any client who joins will have the same name player ship, so the radar will have multiple player ships sending it information. Unless I can tell _GameMgr to use "LocalShip" instead of "playerShip" because there will only ever be 1 "localShip". I don't know, it's all guesswork for me :)
    I'll carry on trying to update the _GameMgr as that might be handy at some point for something.
    What I need to be able to do, I think, is have some c# code as part of my network manager (that spawns the player) to adjust the player and camera values, but this is well beyond my comprehension of scripting, especially as it's having to be c# changing a js script.
    I shall persevere for a bit anyway.

    Cheers
    John
     
  2. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Update...I am able to use "LocalShip" as the player (remember "LocalShip" is the child object of "PlayerShip" Object that gets enabled if the client is local)
    So, I am sure that if I can update the player variable in _GameMgr from within my c# networkmanager script, I will be laughing! I just can't seem to get the syntax error free no matter what examples unity answers or google throw at me.

    BTW, I set the culling of the standby camera to untick all radar and hud stuff, but it's all still there on my lobby menu when I start :(

    The other issues remain, as _GameMgr is definitely at 0,0,0 position & 0,0,0 rotation....could it be because my cockpit camera is not at 0,0,0 in relation to the cockpit object? I haven't tried this yet as I've shut it all down now as I have to sleep :D
     
    Last edited: Nov 3, 2014
  3. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Then the other cameras are probably still active. Make sure to disable the HUD and Radar cameras when your standby camera is enabled.
     
  4. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I'll come back to that problem another time. More important things are troubling me at the moment.
    I have been looking at what you said earlier about updating the _GameMgr stuff....

    The problem is, I need to be able to update those things from within my c# network manager script.
    I have a stand in player and camera, I just can't figure out the c# code to change them to what I need. I can do a GameObject find and get component etc, but the syntax for actually changing the 2 Transforms[] is baffling me. From searching around, I get the impression that I have to get a "class" rather than a component, but I have no idea what that means.
    Hope you can help on this because I don't want to just give up.
    Cheers
     
  5. RowdyMrB

    RowdyMrB

    Joined:
    Dec 8, 2012
    Posts:
    83
    Been working with the Oculus 4.3 beta and the Unity 5 beta (I know, I know I guess I just thrive on the punishment). Anyway, 4.3 completely breaks your C# alpha with a different camera controller setup and drivers. IPD references are changes as well. Your released JS version still works under the Oculus 4.3 and Unity 5 beta configuration. Cheers
     
  6. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    @MajorParts
    In order to access JS from C# you need to setup you project directory structure properly. See the included instructions it's on page 11.

    In your C# script you would call a method like this to replace the player transform.
    Code (csharp):
    1. GameObject.Find("_GameMgr").GetComponent<FX_3DRadar_Mgr>().Transforms[0] = My Player Transform;
    @RowdyMrB
    Yah it pooped all over the C# version didn't it. O well yesterday I started working on converting everything over to use the new 4.6 UI canvas. I'll revisit the rift once things have calmed down with there development changes.
     
  7. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Thanks for getting back. I tried going by what you posted here and that doesn't work...monodevelop says "Unexpected symbol 'Transform'" for the last word.
    I know My Player has to be the name of my player game object, but should there be quotes or brackets there somewhere?
    Sorry for my noobishness :)
    I had already moved the folders as per the manual.

    Cheers mate!
     
  8. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Can you post the line of code you are using?
     
  9. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Code (CSharp):
    1. GameObject.Find("_GameMgr").GetComponent<FX_3DRadar_Mgr>().Transforms[0] = LocalTIE Transform;
     
  10. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    The problem is LocalTIE Transform. You need to access the transform component on a gameObject like this LocalTIE.transform

    Code (csharp):
    1. GameObject.Find("_GameMgr").GetComponent<FX_3DRadar_Mgr>().Transforms[0] = LocalTIE.transform;
     
  11. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I tried that already and I get more errors...FX_3DRadar_Mgr doesn't exist in current context being one, same for LocalTIE and a ? for Transforms[0]
    I thought it may be something to do with LocalTIE being a child of the instantiated player, but even if I change it to PlayerTIE I get the same errors. I'll post the entire player spawn code, that might shed some light for you....

    Code (CSharp):
    1. SpawnSpot mySpawnSpot = spawnSpots [Random.Range (0, spawnSpots.Length)];
    2.  GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate ("PlayerTIE", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
    3.  standbyCamera.SetActive (false);
    4.  
    5.   ((MonoBehaviour)myPlayerGO.GetComponent ("TIEPlayerControl")).enabled = true;
    6.   ((MonoBehaviour)myPlayerGO.GetComponent ("TIEShooting")).enabled = true;
    7.   myPlayerGO.transform.FindChild ("CameraCP").gameObject.SetActive (true);
    8.   myPlayerGO.transform.FindChild ("LocalTIE").gameObject.SetActive (true);
    9.   myPlayerGO.transform.FindChild ("RemoteTIE").gameObject.SetActive (false);
    10.  
    11.   GameObject.Find("_GameMgr").GetComponent<FX_3DRadar_Mgr>().Transforms[0] = LocalTIE.transform;
    I even tried

    GameObject temp = GameObject.Find ("PlayerTIE/LocalTIE");
    GameObject.Find("_GameMgr").GetComponent<FX_3DRadar_Mgr>().Transforms[0] = temp.transform;

    but no luck there either :(
     
  12. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    This means the directory structure is not setup correctly to work with C# to JS. Make sure the Radar Scripts are inside a "Standard Assets" folder and your C# are outside the "Standard Assets" folder.

    By default C# scripts compile before JS so they have no idea that they even exist. When you place JS scripts inside the "Standard Assets" folder this will force them to compile before C# scripts allowing C# scripts to access any JS contained inside the "Standard Assets" folder.
     
  13. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    My project folders are set out the same as the image in your manual. My c# network scripts are in the assets folder and all my other c# scripts are in assets/scripts folder
     

    Attached Files:

  14. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Here is an example C# project. Create a new project, setup your layer names and import this package.\

    You can see how to properly setup your directory structures and you can check out the included C# "FindGameMgr.cs" script to see how it finds the _GameMgr.transform and the FX_3DRadar_Mgr script and assigns them to the properties inside the C#. It will also replace the FX_3DRadar_Mgr.Transforms[0] with the Transform NewPlayer.
     

    Attached Files:

  15. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    I believe the issue is that you have every folder as a sub folder of the "Assets" folder.

    In the manual you can see that the "Standard Assets" folder and the "C# Scripts" folder exist outside the "Assets" folder.
     
  16. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    ah bugger! I don't seem to be able to make folders outside of assets though.

    I want to stress how much I appreciate you helping me with this. You're probably the most helpful person I've ever come across in the history of the internet :)
     
  17. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Perhaps your project folder is bugging out? Not sure how to help with that other than recommend creating a new project and transfer your assets over. You can download the C#_Example.unitypackage file above it is the same as the one you can download on the front page but it has been organized for C# accessibility.
     
  18. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I created a new project and imported your package...that gives me an assets folder (which was there before I did anything) with all your folders inside that (including your new assets folder)
     
  19. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I'm going to have to call it a night...2am here....Tomorrow I shall uninstall Unity and install again.
    Thanks again for putting up with me :)
     
  20. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
  21. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Ok I think I see whats happening. I never have my Project window displayed as two columns which includes the Main Assets folder from the project root directory. When the Project window is displayed as one column you do not see the root Asset folder.

    This is how it will look with the Project window set to two column / Favorites.

     
  22. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Good news! Even though I still get the "FX_3DRadar_Mgr" does not exist in current context", the project still runs and assigns relevant objects! After some tweaking of what objects have the RID script, it also works for multiplayer. Well, some things are still broken, like the bounds being in front when the target is behind, the center arrow not moving and the edge icons also not moving, but at least other players are targetable!

    Thanks for all the help getting me this far!
     
  23. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Strange... At least something ended up working. :)

    All your clients are running their own FX_3DRadar_Mgr scripts right?

    In a few days I'll have an updated C# version for normal desktop monitor development that uses the Unity 4.6 UI instead of my own Orthographic projection method.
     
  24. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    I was thinking about your stuck HUD elements this is the only thing I can think of.

    If your clients are sharing a single FX_3DRadar_Mgr and the targets are sharing a single FX_3DRadar_RID script then every client will see the HUD as seen from which ever object is assigned as the player & player camera in the FX_3DRadar_Mgr. This means if client 4 is assigned to these asset slots then only client 4 will have a properly working HUD and the rest of the clients will only see the HUD as client 4 sees it.

    Make sure that every client is running locally their own FX_3DRadar_Mgr and each local target is running its own FX_3DRadar_RID.
     
  25. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Most of my tests are being done in a single player environment and the HUD stuff isn't working right.

    For multiplayer, I have (all renamed here for simplicity sake).....

    PlayerSHIP object (controls + laser scripts attached - no gfx)
    this has the following child objects
    RemoteSHIP child (RID script attached - full ship GFX)
    LocalSHIP child (RID script attached as player - cockpit GFX) .... disabled
    GunTips child (irrelevant)
    CameraCP child .... disabled

    When the game is run, if the player is yourself, then PlayerSHIP is spawned, RemoteSHIP disabled, LocalSHIP enabled, CameraCP enabled....otherwise the spawning player is treated as a Remote player and spawns Playership, leaving LocalSHIP and CameraCP disabled.

    So, on your machine, there is only ever one LocalSHIP and one camera. These are the objects that are attached to the FX_3DRadar_Mgr
     
  26. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I may be able to zip up the project to a file host site or something if you want to take a look?
     
  27. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    If you want you can PM me and I'll check it out
     
  28. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Last night I finished converting all the HUD & Radar elements to Unity 4.6 new UI system. To my surprise I discovered a few disappointing things.

    The following results are based on a stress test of 200 targets (this equates to about 1400 HUD / Radar UI elements) while rendering only the HUD / Radar UI elements. All mesh.renderers that are not UI elements have been disabled.

    1. The new UI does not batch as well as my custom method and ended up using 30 draw calls vs 2 draw calls of my own method.
    2. The new UI is slower at 23 fps vs 78 fps. I have not run the profiler to see where the slowdown is yet.

    Using the UI system requires per frame level access to the <RectTransform> & <Image> components of each HUD element, so these components have been cached to prevent GetComponent<>() calls every frame.

    Given this I have decided not to use the 4.6 UI to render the HUD / Radar elements, instead I will only use the new UI to render the targeting list, HUD information display such as target distance & possibly status bars.
     
  29. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Fantastic news. The new Unity 4.6 RC1 has been massively improved.

    Before the UI as designed for the HUD & Radar system was extremely slow when lots of targets were on screen resulting in script execution times of 30+ms. Now with the new RC1 release the same setup of 100 targets runs in less than 1ms coming in at 0.72ms. This is now beating my custom rendering method which clocks in at around 1ms to 1.60ms per 100 targets.

    I have also made improvements for the target bounding corner indicators. Instead of four sprites (1 for each corner) I am instead using a single sliced sprite.

    In short progress on the UI conversion is commencing once more.
     
    schmosef likes this.
  30. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Sounds good!

    I had a mess around with sub-components last night and not sure if I'm doing it right. I can press M & N and have a little beep set up, but I don't get any sort of target on the component. Well, another box appears inside the main object box, but I thought the actual sub component would have it's own box?
    This is on the turrets of the star destroyer.
     
  31. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Sorry I'm not sure I under stand. When you select a target's subcomponent you get a secondary targeting indicator aka the SubComponent target indicator that is placed over the selected subcomponent. This SubComponent indicator is only displayed when a subcomponent is selected Is this not happening?

     
  32. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    No it's not. I have a target box appear on the main object, then a slightly off-center box within the main object box when a sub component is targeted. I will load up your demo scene again and make sure I have it all set up as you do, but I'm sure it is.
    I'm running into all sorts of other problems with this project now though and your radar/targeting is probably the only thing that works anywhere near how it should. I think I've set myself too complex a project to be honest and will probably shelve it until my knowledge of Unity and scripting etc has increased considerably.
     
  33. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I think I know why....the turrets are part of the model and so position is 0,0,0
    I'm going to leave it alone for a bit. I can't seem to alter the position values even if I drag the mesh out of the main object...as soon as I attach it it again, the position reverts to 0,0,0
    I shall come back to it in a few days....taking too much of my time for little to no results :(
     
  34. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Correct. If the turrets are mesh combined with other objects then they will share the same world position. You can create empty gameObjects at the location of the turrets with the tag of SubComponents. This should give you the result you want.
     
  35. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Cheers. That works, but I'll have to redo the model to have separate turret meshes anyway or I won't be able to destroy them.
    I really have bitten off more than I can chew with this though. I'll probably make pacman instead :D
     
  36. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Lol don't give up the new UI Radar is getting so close!!
     
  37. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Here it is running completely on unity 4.6's new UI system, no OnGUI or custom draw methods, except for the radar object it still uses its own camera. It's not quite ready yet but it is getting there and yes that is a dynamic & responsive scrolling target list.

     
  38. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I have another confusing problem you may be able to help with...

    I have now managed to spawn different ships depending on which team is joined but I'm having trouble with the faction side of things.
    I have a number of stationary targets set to "rebel" faction and a capital ship set to "imperial" faction.
    If I spawn as "imperial", the targets of "rebel" show up as red and the "imperial" is blue.
    If I spawn as "rebel", the colours are the same.

    I have 2 factions in the faction mgr, imperial & rebel and they are set to id 0 & 1

    When the player spawns, depending on what team he chooses, the spawn script assigns a player faction...example for joining "imperial".....

    Code (CSharp):
    1. GameObject.Find("_GameMgr").GetComponent<FX_Faction_Mgr>().PlayerFaction = 0;
    and Player.Faction = 1; if "rebel"

    The prefabs are set up correctly with RID script faction set.

    I've read both pdf's but can't figure this out. Any idea what I'm missing?

    Cheers
     
  39. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    I deleted the last post because I think I know what’s going on. You are changing the players faction after the game has initialized. This is what’s happening.

    1. You have a default faction set in the Faction Mgr script.
    2. The game starts and IFF values are calculated during the Awake/Start methods.
    3. The player gets a new faction during runtime. Now the IFF values from step 2 are no longer valid unless they kept the same faction as defined in the Faction Mgr script from step 1.

    I need to make a function that can be called to recalculate the IFF values of all FX_3DRadar_RID scripts during runtime. This can be done by calling FX_3DRadar_RID.SetIFFStatus(); But I need to make a method is so that it can be pushed to all objets with an RID script.
     
    Last edited: Nov 10, 2014
  40. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    This is untested.

    Add this to the FX_3DRadar_Mgr script.

    Code (csharp):
    1. fucntion ResetIFFStatus(){
    2. var Objects : GameObject[] = FindObjectsOfType(GameObject);
    3. for(var o : GameObject  in Objects){
    4. if (o.GetComponent(FX_3DRadar_RID)){
    5. o.GetComponent(FX_3DRadar_RID).SetIFFStatus();
    6. }
    7. }
    8. }
    Call this function after you assign the players faction

    Code (csharp):
    1. GameObject.Find("_GameMgr").GetComponent<FX_Faction_Mgr>().PlayerFaction = 0;
    2. GameObject.Find("_GameMgr").GetComponent<FX_3DRadar_Mgr>().ResetIFFStatus();
     
  41. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Cheers mate! I will look at adding this in a bit. I just tested online with a mate and although it doesn't work right yet, it looks bloody good with someone else flying about shooting :D
     
  42. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    That's awesome! It's always good to see something you've worked hard on come to life. :)
     
  43. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I added the bits you mentioned and I get an error in the RID script now....

    NullReferenceException: Object reference not set to an instance of an object
    FX_3DRadar_RID.SetIFFStatus () (at Assets/Standard Assets/ForceX 3D Radar/Scripts/FX_3DRadar_RID.js:969)

    The line of code is...

    Code (JavaScript):
    1. }else if(ThisFaction[2] == FX3DRM.FXFM.PlayerFactionID && !IsObjective){
     
  44. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    I'm home from work now. This works for me. Remove the previous segment of code and use this instead where you are changing the players faction number.

    Code (csharp):
    1. void ChangePlayerFaction () {
    2.         FX_Faction_Mgr FXFM = GameObject.Find("_GameMgr").GetComponent<FX_Faction_Mgr>();
    3.         FXFM.PlayerFaction = 0;//<------------- Change Player Faction Here
    4.         FXFM.PlayerFactionID = FXFM.FactionID[FXFM.PlayerFaction];
    5.      
    6.         GameObject[] Objects = FindObjectsOfType<GameObject>();
    7.         foreach(GameObject o in Objects){
    8.             if (o.GetComponent<FX_3DRadar_RID>()){
    9.                 o.GetComponent<FX_3DRadar_RID>().SetIFFStatus();
    10.             }
    11.         }
    12.     }
     
  45. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Sorry, got busy with other stuff.

    So that last bit of code is for my network manager I presume? I will try it now anyway and see what happens, cheers! :)
     
  46. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Correct. Use this bit of code when you are setting the players faction during runtime. Ignore the previous code segments I posted before, if you still have them you can remove them. This is an all in one solution that you can call from your own script. No need to modify any of the Radar scripts.
     
  47. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    I must be doing something wrong then as nothing is changing. friendly are still red, enemy are still blue and I still get the error I mentioned :S
     
  48. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Are you using version 1.2.1b or 1.1.9e from the front page download links? Running 1.2.1b demo in a clean project I don't get this error when executing the change player faction code.

    Can you PM me the updated script you are using to swap the players faction. When I get home from work I can import it into the project you sent me to test it out.
     
  49. MajorParts

    MajorParts

    Joined:
    Sep 27, 2014
    Posts:
    88
    Certainly. I'm not sure the code is now compatible with what I sent you before, as I made quite a lot of changes to how the player spawns. There is a menu to select teams, then another to select ship type. I'm calling the same "changeplayerfaction" function after both teams player instantiation, but I will amend that to reflect what team is chosen once I get the "rebel" selection working.

    Just to clarify here....

    In the scene, I have stationary targets with faction selection at "rebel.........1". The faction ID says 0. When run, this changes to 2
    The destroyer faction selection is at "imperial...........0". Faction ID says 0. When run it changes to 1

    Because when I started this, I only had an imperial player, so the player faction in "faction_mgr" was set to "imperial". This is what needs to change.

    The "rebel" player prefabs faction selection is "rebel............1". Faction ID is 0. When run it stays at 0 even though with your last code setting it to anything. The player faction in "game_mgr" is changing as it should now though. So this is what is confusing me about the target faction colours.
     
  50. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Quick question. On this line
    Code (csharp):
    1. FXFM.PlayerFaction = 0;//<------------- Change Player Faction Here
    You are changing the "0" for your new faction "int" value correct?