Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Space Combat Kit (VSXGames) [RELEASED]

Discussion in 'Works In Progress' started by Billy4184, Jul 14, 2015.

  1. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    The DemoManagerMain.cs script controls the setting up and management of the demo scene. Looking through it will give you the starting point for understanding how any part of the demo is created.

    Absolutely. There will also be more demo scenes focused on smaller parts of the kit, because a lot of what happens in the main gameplay demo is instantiated from prefabs and controlled dynamically by the demo manager script, making it hard to isolate things.

    What do you mean exactly? Camera view targets are a part of each vehicle - if you don't want exterior view for example you can remove that CameraViewTarget component from the vehicle prefab.
     
    schaefsky likes this.
  2. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK I am getting complier errors and I am using the 3.8 update and I even went back and tried it out in the 2.8 version but still getting the complier error so can't play the demo . Can I get some help with that please? I even made a new install still getting that complier error
     
  3. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    Can you post a screenshot of the errors?
     
  4. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    Hi Billy, I'm am trying to Create a log message for every time an Enemy gets destroyed. How do I go about this?
     
  5. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    To destroy a vehicle, you call its SetActivationState method with a state of 'Destroyed'.

    To kill a Game Agent, you call its SetActivationState method, with a state of 'Dead'.

    When a game agent enters a vehicle, it subscribes to the event of the vehicle activation state being changed, so that when the vehicle is destroyed, the game agent is killed.

    The vehicle is destroyed by its Health component when the health reaches zero.

    In short, if you want to catch the event of a game agent being killed, you would subscribe whatever function you want to run to its OnAgentChangedActivationStateEventHandler delegate (soon to be a Unity Event).

    Let me know if anything doesn't make sense.
     
    JFI66 likes this.
  6. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK No problem will get some screenshots up later
     
  7. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK here is a screenshot trying to open Space Combat Kit in Unity 3.8

     
  8. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    Please post a screenshot of the console tab with the error highlighted, otherwise I have no idea what the errors are about.
     
  9. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK
     
  10. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    2019-03-18 at 14-33-32.png

    Here is an image not sure its too clear though so I will post another screen video
     
    Last edited: Mar 18, 2019
  11. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
  12. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Here is the video
     
  13. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    See my last comment, I need to see the errors, not warnings.
     
  14. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    2019-03-18 at 15-23-57.png

    Here it is, sorry about the warnings
     
  15. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Is the picture clear enough?
     
  16. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Here is probably a better picture 2019-03-18 at 15-22-48.png
     
  17. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    These errors have nothing to do with the Space Combat Kit that I can see. If you remove the SpaceCombatKit folder from the Assets folder do they go away?
     
  18. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    I have deleted the Space Combat folder and reinstallled it with a fresh install still getting these errors
     
  19. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    What I mean is, if you delete the SpaceCombatKit folder (and don't reinstall it) do the errors disappear? If they are still there, then SCK is not the problem.

    The errors are about analytics stuff, and SCK has nothing to do with that.
     
  20. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK I will de install it and get back to you with the results
     
  21. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Getting this error in the console after a clean install and adding the Rewired intergration

    ''There are inconsistent line endings in the 'Assets/SpaceCombatKit/Scripts/SpaceCombat/HUD/HUDSecondaryWeaponInfoController.cs' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.''
     
  22. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    And no the errors don't reappear
     
  23. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    Cool I'll fix that. If you open it in Visual Studio you'll get a popup with an option to fix it too.
     
    JFI66 likes this.
  24. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK good thanks
     
  25. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    I think I will leave it to you as I will only mess it up
     
  26. schaefsky

    schaefsky

    Joined:
    Aug 11, 2013
    Posts:
    66
    So do you have an ETA for the next update? :)
     
  27. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    Hi Billy, How do we add a second Friendly ship prefab into the demo manager? I want to add a secondary ship type.
    Is this a simple as making this gameObject prefab an array?
     
  28. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    In what context do you want the new ship to be instantiated? The demo manager script is just for the creation and management of objects in that demo scene, it's not meant to be a generic level management script, though you can reuse parts of the code for doing specific things.
     
  29. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    It's getting there. I'm updating the Vehicle Combat Radar asset (which will go directly into the updated Space Combat Kit) right now. It's probably the part of the kit that is most ripe for change/improvement.

    I'm about to put up a WebGL of this radar update for you guys to play with which includes:
    • Load up multiple radar trackers on a ship for different types of targets (instead of just one 'Radar' script).
    • Have multiple target selectors running at the same time (e.g. waypoints and weapon targets).
    • Create and target subsystems (trackable hierarchies).
    • Highlight targeted subsystems.
    • Define the target bounds in the inspector.
    • No more interfaces where they don't belong!
    • Easily extend all of the scripts from the radar to the HUD with your own stuff.
    In terms of functionality, it's about as complete as I can think of right now, and hopefully it will give you everything you need in a radar!
     
  30. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    I wanted to have more than one friendly ship type. I have picked apart the code as of yet but is there an easy way of doing this?
     
  31. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    Just to elaborate on this.. I wanted a secondary friendly group to spawn along side the existing friendly group with a different prefab. I have tried copying the code in the demo manager and adding a new object with the AIFighterSkill but when the scene loads the new object is just static and doesn't move. I want this ship to move about and get attacked by the enemy. Im finding this kit a bit of a jigsaw at the moment.
     
  32. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    I forgot to add this object to the friendly group manager. All working now. Really looking forward to the new update. I had to recreate a new unity account recently so will buy again to support you when it releases :)
     
  33. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    Glad you got it working! I will make sure that even the demo manager uses more reusable scripts (such as a ship spawner and player spawner) to make things clearer.

    I appreciate the support! However if your new account has lost access to the space kit asset on the store, I'm sure Unity will be happy to help you fix that, and if not I might be able to sort something out, drop me a PM. There will be more packages coming onto the store soon so you'll have plenty of opportunities spend your money and get some fun stuff!
     
    JFI66 and xsocomx like this.
  34. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    Sounds great thanks billy :)
     
  35. fea777

    fea777

    Joined:
    Jun 29, 2015
    Posts:
    2
    does this work on mobile and has mobile controls?
     
  36. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    I haven't done much mobile testing recently, but there's no reason why not. There aren't any mobile controls implemented - its on the todo list.
     
    JFI66 likes this.
  37. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    I'm trying to display the health bar of a friendly unit on the canvas . Is there a way I can log the health value of a specific unit? cant seem to figure it out.
     
    JFI66 likes this.
  38. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    From the ship's Health component, you can use the following functions:

    GetCurrentHealthFraction (HealthType healthType) - a value from 0-1 for the fraction of starting health remaining

    GetCurrentHealthValue (HealthType healthType) - the current health value for a specified health type.

    GetStartingHealthValue (HealthType healthType) - the starting health value for a specified health type.
     
    JFI66 and xsocomx like this.
  39. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    thanks billy, but how do i find the health a friendly unit specifically. For example the first friendly ai ship in the demo scene?
     
  40. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    A code example would be super helpful :)
     
  41. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    Can you explain in more detail what you're trying to do?

    Normally your would store references to your ships based on the context in which they will interact with the player. For example, if you want a specific ship to attack the player at a specific time, you would create a script with a reference such as 'Vehicle playerAttacker' and drag the ship into that reference in the inspector, and add your code for whatever you want to do later on in the script.

    In any case, if you're using the DemoManagerMain script, it declares two lists at the beginning:

    Code (CSharp):
    1. [SerializeField]
    2. private List<GameAgent> friendlies = new List<GameAgent>();
    and

    Code (CSharp):
    1. [SerializeField]
    2. private List<GameAgent> enemies = new List<GameAgent>();
    These are the lists of Game Agents for the friendlies and enemies. Remember that ships/vehicles do not represent specific characters in this kit, Game Agents do.

    If you want to access the health of the first friendly player ship in the list, you could do something like:

    Code (CSharp):
    1. float health = friendlies[0].Vehicle.Health.GetCurrentHealthValue(HealthType.Shield);
    of course, it's usually a good idea to check if the list of game agents is not empty, if the game agent is in a vehicle, if the vehicle has a health component, and so on before you try to access them, but you get the idea.
     
    xsocomx likes this.
  42. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    Thanks Billy that perfect :)
    It's hard when its someone else's code. I love this kit it has so much versatility.
    I appreciate your support thanks so much for taking the time out of your day for me.
     
    JFI66 and Billy4184 like this.
  43. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    No problem! There's plenty of video tutorials and documentation to make, but first I need to make sure the code is as easy to use as it can be. I'm sure this update will really help you out!
     
    JFI66 likes this.
  44. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    One last thing. is it possible to change ship while in the demo scene. I,e press F to switch from controlling player ship to controlling the friendly ship. I basically on death i want to switch ships to one of the squad ships.

    I saw changing vehicles in the doc but cant figure it out.

    Another code snippet would be amazing :)
    Thanks again bud.
     
  45. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    Do you want the player to retain their identity, or to take on the identity of another squad member?

    For the first case, the EnterVehicle function on the Game Agent script can be called to make a Game Agent enter a new ship, or you can pass NULL to make the game agent exit a ship. So you can grab a reference to another squad member's ship, make them exit it, and make the player enter it.

    For the second case, it's a little more complicated. You would basically swap out the input components for the other squad member from AI input to player input. It's not totally achievable right now with the way things are set up, but I can help you add it.

    I think it would also really help if you try to set it up yourself, and then let me know where things go wrong. That way I can see exactly where the sticking points are and try to improve things.
     
    xsocomx likes this.
  46. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    Awesome, I will have a play around and let you know.
     
    Billy4184 likes this.
  47. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    Hi Billy, Sorry to be a pain again. Is there a way I can detect a hit on a friendly ship in the demo scene? Ideally I would like to do this in HUD Messages
     
    Last edited: Mar 24, 2019
  48. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    The Health component of the ship has the following delegate:

    Code (CSharp):
    1. public delegate void DamageEventHandler (float damageValue, Vector3 hitPoint, GameAgent attacker);
    2. .
    3. .
    4. .
    5. public DamageEventHandler damageEventHandler;
    If you create a script with a function that matches those parameters, you can make it get called when a ship is damaged by grabbing the Health component of the ship and adding your function to the damage delegate - e.g. '
    Code (CSharp):
    1. someVehicle.Health.damageEventHandler += MyMethod;
    '
     
    xsocomx and frankadimcosta like this.
  49. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    33
    thank you once again :)
     
    Billy4184 likes this.
  50. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,284
    Hey guys, just a bit of an update with some great news on how things are coming along with the radar/trackables update!

    Dynamic Variables for Trackables

    I've set up a system where you can add dynamic values to your Trackables in the inspector without having to write code.

    How it works

    You create a variable on the Trackable inspector, link a property in another script to it (such as a Health value in your Health component) in and then you can grab that variable by string key anywhere in the code from the Trackable. It's very similar to adding methods to Unity Events

    It is likely going to be possible to also write the variable back to a property in another script (e.g. a component that controls a health bar) in the inspector as well. However because the radar/target tracking list changes all the time it will be necessary to create some components where you can define the key and the script takes care of grabbing the value and setting things like text fields or value bars.

    In short it will be possible to create your own trackables that track information from other components and visualize them on the 3D radar or HUD, without having to code!

    Why

    This is a pretty exciting thing because over the last few days I've been struggling to create a system of base classes that are easy to extend in terms of creating your own Trackables (e.g. waypoints, ships, an asteroid with mineral information etc). Extending the Trackable class is not an easy problem to solve, because the entire tracking system consists of multiple components:
    • Trackables
    • Trackers
    • Trackable Selectors
    • Trackable Visualizers (target boxes and 3D radar scripts)
    • etc
    each of which potentially needs to access Trackables by the derived class rather than the base class. Because trackables are dynamically stored in lists which can't easily be cast back and forth between base and derived types, you end up with a nightmare of parallel lists between base classes and derived classes, making extending the radar messy and tedious.

    Whats Next

    The only potential downside for this approach is a small performance hit. Although I've found a way to utilize reflection without any allocations/garbage at all, and initial testing with the Profiler is OK (1-2ms for 200 targets each with 10 variables getting read once each - 2000 variable reads - on a laptop) I need to finish off the framework and make sure there's no real-world use cases that are going to trip things up.
     
unityunity