Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Space Game Starter Kit [Released]

Discussion in 'Assets and Asset Store' started by ArenMook, Oct 11, 2011.

  1. Phill123

    Phill123

    Joined:
    Jul 29, 2012
    Posts:
    11
    Thanks for all your help - it is very much appreicated
    That compiles fine but i must have something fundamentally flawed elsewhere as my explosions still stand still :(
    At least i know the code is right now so i can try to find whatever else is wrong.

    Cheers
     
  2. Phill123

    Phill123

    Joined:
    Jul 29, 2012
    Posts:
    11
    well 4 days later and i am still stuck. I've even recreated my project from the beginning but still no moving explosions.

    the gameunit.cs code is:

    using UnityEngine;
    using System.Collections.Generic;

    [AddComponentMenu("Game/Unit")]
    [RequireComponent(typeof(NetworkView))]
    public class GameUnit : GameFaction
    {
    public delegate float OnDamageCallback (float damage);

    public float currentHealth = 100f;
    public float maxHealth = 100f;
    public GameObject explosionPrefab;

    List<DamageReduction> mProtection = new List<DamageReduction>();

    /// <summary>
    /// Unit's current health in percent.
    /// </summary>

    public float healthPercent { get { return Mathf.Clamp01(currentHealth / maxHealth); } }

    /// <summary>
    /// List sorting function.
    /// </summary>

    static int SortProtection (DamageReduction a, DamageReduction b)
    {
    if (a.layer < b.layer) return -1;
    if (a.layer > b.layer) return 1;
    return 0;
    }

    /// <summary>
    /// Find all damage protection and sort it.
    /// </summary>

    protected override void OnStart ()
    {
    DamageReduction[] prots = GetComponentsInChildren<DamageReduction>();
    foreach (DamageReduction pro in prots) mProtection.Add(pro);
    mProtection.Sort(SortProtection);
    }

    /// <summary>
    /// Apply damage to the unit.
    /// </summary>

    public void ApplyDamage (float damage)
    {
    // Negative damage means healing, and there is no point in healing if the unit has full health.
    if (damage < 0f currentHealth == maxHealth) return;

    if (!NetworkManager.isConnected || mView.isMine)
    {
    ApplyDamageRPC(damage);
    }
    else if (!NetworkManager.HasBeenDestroyed(mView))
    {
    mView.RPC("ApplyDamageRPC", mView.owner, damage);
    }
    }

    /// <summary>
    /// RPC callback applying damage to the unit. Sent only to the unit's owner.
    /// </summary>

    [RPC] void ApplyDamageRPC (float damage)
    {
    if (currentHealth == 0f) return;

    // Decrease the damage using all available protection
    if (damage > 0f)
    {
    for (int i = mProtection.Count; i > 0; )
    {
    DamageReduction prot = mProtection[--i];

    if (prot == null)
    {
    mProtection.RemoveAt(i);
    }
    else
    {
    damage = prot.OnAbsorbDamage(damage);
    if (damage == 0f) break;
    }
    }
    }

    // Decrease the hull's health
    currentHealth = Mathf.Clamp(currentHealth - damage, 0f, maxHealth);

    if (currentHealth > 0f)
    {
    // Inform others of the unit's current health
    if (NetworkManager.isMultiplayer)
    {
    mView.RPC("SetHealthRPC", RPCMode.Others, currentHealth, maxHealth);
    }
    }
    else // Once the health drops below zero, destroy the unit
    {
    // Instantiate an explosion prefab

    {

    GameObject go = Instantiate (explosionPrefab, transform.position , Quaternion.identity) as GameObject;
    go.rigidbody.velocity = new Vector3(0,0,-30);
    }

    // Destroy this unit
    NetworkManager.RemoteDestroy(gameObject);
    }
    }

    /// <summary>
    /// RPC callback setting the unit's current health.
    /// </summary>

    [RPC] void SetHealthRPC (float current, float max)
    {
    currentHealth = current;
    maxHealth = max;
    }
    }

    Have i got this completely bungled or should this work?

    Cheers
     
  3. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Wrap your code in a [ code ] block, or it's difficult to read.

    In order for physics to work properly your explosion must have a rigidbody and a collider on it.
     
  4. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Bump -- just a note, a version of this kit with an NGUI-based UI is now available and can be acquired upon request. I'm wondering if I should just update the package or keep it as-is with the NGUI version being optional?
     
  5. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    I'd like an Ngui version if possible. Optional would give you more scope I guess, with the NGui version being another showcase for NGui and the non version being open for new Unity4 UI and others.
     
  6. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    For anyone who wants the NGUI version, just toss me an email to support at tasharen.com (with your invoice #), and I'll send you a link.
     
  7. Archania

    Archania

    Joined:
    Aug 27, 2010
    Posts:
    1,662
    Just to let you know with Unity 3.5.5f3, I'm getting warnings:

    Assets/SGSK/Scripts/Common/Other/PerformanceMonitor.cs(20,41): warning CS0618: `UnityEngine.QualitySettings.currentLevel' is obsolete: `Use GetQualityLevel and SetQualityLevel'

    Assets/SGSK/Scripts/Common/Internal/QualityRequirement.cs(10,59): warning CS0618: `UnityEngine.QualityLevel' is obsolete: `See QualitySettings.names, QualitySettings.SetQualityLevel, and QualitySettings.GetQualityLevel'

    Assets/SGSK/Scripts/Common/Other/RealtimeCubemap.cs(35,97): warning CS0618: `UnityEngine.QualityLevel' is obsolete: `See QualitySettings.names, QualitySettings.SetQualityLevel, and QualitySettings.GetQualityLevel'

    This doesn't effect anything, I just wanted to point it out.
     
  8. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Yup that would be because the asset store package was built with Unity 3.4.2 I think. There is an updated version available on-demand that uses NGUI for its UI, I fixed the warnings there.
     
  9. bariscigal

    bariscigal

    Joined:
    Oct 26, 2009
    Posts:
    46
    I have tried other assets for spaceship/airplane game kits and i think this one plays the best.

    I would love to know why this happens also. Or how to change would be a better answer for me.

    Also i bought this for a Jet plane game i am building.( As an answer to a question before) The controls and dynamics are pretty sweet for an arcade controller of the plane but it certainly needs a bit tweaking.
     
    Last edited: Sep 20, 2012
  10. ineteye

    ineteye

    Joined:
    Sep 12, 2012
    Posts:
    35
    Hi!
    I need to add a second rigid body for interaction... But the problem it did not moves with ship...
     
  11. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Second rigidbody? Only one rigidbody can be used per movable object.
     
  12. ineteye

    ineteye

    Joined:
    Sep 12, 2012
    Posts:
    35
    So if root have rigid body .. parent with rigid body will not move at all? ...So if i will need that i have to dublicate rigidbody postition to parent...
     
  13. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Rigidbody is like a container holding one or more colliders that will interact with physics. I suggest brushing up on how it all works in Unity.
     
  14. ineteye

    ineteye

    Joined:
    Sep 12, 2012
    Posts:
    35
    Just wanna to disable camera Roll from mouse input.. Can you advise best way? )) Thanks ))
     
  15. ineteye

    ineteye

    Joined:
    Sep 12, 2012
    Posts:
    35
    Just wanna to disable camera Roll from mouse input.. Can you advise best way? )) Thanks ))
     
  16. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    SpaceshipController line 165:
    Code (csharp):
    1. turn.z = Input.GetAxis("Roll");
     
  17. ineteye

    ineteye

    Joined:
    Sep 12, 2012
    Posts:
    35
    Thanks )) But that a bit not what i am looking for... this only disables key... but camera roll still will be work... so if make some rotion on 360 ... camera will not be paralleled to floor and shoot cross all will be rolled side...
     
  18. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    It sounds like you're trying to make something very different from what I have in there. Either way though, you will want to modify the SpaceshipController.
     
  19. Scobbo

    Scobbo

    Joined:
    Aug 18, 2012
    Posts:
    43
    Hey this looks exactly like what I was looking for! I will be starting a project very soona and this will cut production time dramatically. Before I purchase it I have just 2 questions, it it working with the latest build of Unity (3.5.6) and does it require pro, or what parts require pro?

    Excellent work and look forward to your response!
     
  20. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Yeah it's working there, but has warnings. I have an updated 3.5+ version that doesn't have warnings and uses NGUI. To get that one all you have to do is PM me the invoice #.
     
  21. bariscigal

    bariscigal

    Joined:
    Oct 26, 2009
    Posts:
    46
    Hello again. I would like to get a reply on this one. Any possible ways?
    Or is there no solution?

    In short: how can i change the roll rotation pivot? It is based on the camera view right now.

     
    Last edited: Oct 4, 2012
  22. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I can advise you of a way to do this when I return from my trip on the 13th.
     
  23. ineteye

    ineteye

    Joined:
    Sep 12, 2012
    Posts:
    35
    Also ... need advise about how to change camera... as i found in script .. it did not parented, it just folowing the player...
     
  24. WhiteRabbit

    WhiteRabbit

    Joined:
    Jun 16, 2011
    Posts:
    13
    Aren-
    I downloaded the new Unity 3.5.6f4 version, created a new project with the kit and it fails to create a host when running welcome scene. The first error message is "Asynchronous Background loading is only supported in Unity Pro". I'm running the free version of Unity.

    Additional error messages include "NullReferenceException: Object reference not to an instance of an object, flagging line 387 in NetworkManager.cs.
     
  25. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Hmm... was that changed in 3.5.6? Replace Application.LoadLevelAsync with Application.LoadLevel then.
     
  26. WhiteRabbit

    WhiteRabbit

    Joined:
    Jun 16, 2011
    Posts:
    13
    Thx.. I use this kit to try to help my kids learn something about programming -- so I revisit it every few months when they show an interest. I have to keep reinstalling Unity and your kit... and ALWAYS seem to forget that, duh... ProjectSettings has to be replaced.. that was the main problem again. Sorry about that.
     
  27. Scobbo

    Scobbo

    Joined:
    Aug 18, 2012
    Posts:
    43
    Hi Aren,
    I was wondering if there was a walk through of all the components in this package, not going in depth with the code, but just saying here these scripts do this and should be attached to this object. You know just a quick look at everything because I'm having to go searching at the moment for the things like variable names and what script they are attached to and what object or object's child just to alter the stats of a ship if they choose a different class of vessel. If there isn't I'll keep doing it this way but if I have missed a writeup or video I'll kick myself.

    Cheers!
     
  28. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    You haven't missed anything. Everything is in-code for developers. As I recall the structure was pretty modular. Certain ship components (such as shield, engines, lasers) require power to work, so they automatically try to find a power generator on the ship. There can be one or more of the generators, and each generator can have a varying amount of power output. Components themselves drain a certain amount of power from the generator -- so while the inertia dampener is active, it drains more power than the generator is able to output, resulting in the power reserve going down.

    Since the ship that comes with the starter kit only has one power generator, this makes it quite vulnerable to enemy fire. You can add a secondary (dedicated) power generator for the shields to make the inertia dampener not drain the power used for shields, creating a more "safe" version.

    I figured doing it this way makes it very easy for developers to create different custom ship types, and even make them customizable by players -- upgrading power generators, installing new ones, adding more powerful components, and so on -- customizing the ship to how they want it.
     
  29. rtslick

    rtslick

    Joined:
    Sep 9, 2012
    Posts:
    1
    I absolutely love this starter kit but I did have one question though. I have been trying to implement some first person level with the kit. The space portion works great but the first person prefab has an ultra sensitive camera movement and the move keys do not work. It only does this one project, since I had to copy over the project settings zip. I was wondering if you had a fix for this or suggestions on this.

    Thank You
     
  30. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    You can adjust the sensitivity in the Input Manager in Unity.
     
  31. WhiteRabbit

    WhiteRabbit

    Joined:
    Jun 16, 2011
    Posts:
    13
    Finally was able to start spending some time with this. First thing I noticed is that after unzipping the Project Settings and running it, assertions are popping up regarding the Input settings. There are several axes named "Up", "Right", "Look Up", etc. in SpaceShipController.cs - none of which are in the Input Manager and consequently generate errors. What am I missing?
     
  32. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Unzipping the contents of the Project Settings zip file into the Project Settings folder is what sets up the axes.
     
  33. Rose-Remnant

    Rose-Remnant

    Joined:
    Nov 14, 2012
    Posts:
    123
    Hi, this may be stupid but is possible to replace the exsiting ship with a new model to make this your own game with your own models, and will that screw with anything?
     
  34. Archania

    Archania

    Joined:
    Aug 27, 2010
    Posts:
    1,662
    Last edited: Nov 14, 2012
  35. Rose-Remnant

    Rose-Remnant

    Joined:
    Nov 14, 2012
    Posts:
    123
    Cool then when I get some cash I will start working on it!
     
  36. maspi

    maspi

    Joined:
    Feb 8, 2011
    Posts:
    18
    Hy Aren
    The SGSK is great!

    In Unity 3.5 I begun to integrate the SGSK (V.1.14) in an existing JS-Project. Everything worked well.
    Yesterday I integrated a piece of code to get some compensation for the position of the mobile device.
    http://forum.unity3d.com/threads/14743-Reset-Accelerometer-Is-it-possible/page2

    Today I realized a jitter in movement. Deactivating the changes for compensation to the SGSK standard code won't help.

    What could be the reason for the jitter?
     
  37. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Can be any number of reasons. The ship is moved by physics, which is often lower than the framerate. If the camera is following a ship, it will appear to jitter because of its higher framerate. To address it, I usually separate the rendering from the physics -- that is have the renderers follow the physics object with a dampened spring effect. The rigidbody ends up being in a slightly different position than the renderer as a result, but the jitter is fixed.
     
  38. maspi

    maspi

    Joined:
    Feb 8, 2011
    Posts:
    18
    Thank you Aren
    I went back to a 2 days older version of the project and repeated al the coding steps.
    Now it seems to work as expected.
    I'll remember your answer, if the jitter should appear again.
     
  39. Distant_Temples

    Distant_Temples

    Joined:
    Apr 14, 2012
    Posts:
    131
    I just got TNET was wondering if you had a build of SGSK with TNET incorporated in to it like you did with NGUI.
     
  40. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Yes, actually. :)

    I am currently doing just that, so Soon™...
     
  41. Distant_Temples

    Distant_Temples

    Joined:
    Apr 14, 2012
    Posts:
    131
    Way cool! Will go buy it now. Please let me know when you get it wrapped up.
     
  42. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    This kit is now available with NGUI UI and TNet for networking. You can request it by providing invoice numbers for all 3 packages via email (support at tasharen.com), and I will hook you up with a single package that contains all 3.

     
    Last edited: Dec 29, 2012
  43. Distant_Temples

    Distant_Temples

    Joined:
    Apr 14, 2012
    Posts:
    131
    WOW, This kit rocks! I was really impressed with it before I got the build that combines it with TNet and NGUI. I was able to get it up and running right away. I found it real easy to muddle through the code and customize stuff. Also I spotted a lot of places that I will be returning to and making customizations. This is great for a guy like me that does "OK" with making changes to an existing code base.

    While it does have code that I will have to sit down with to learn about there is much in here that is straight forward and well commented which makes it easier for me to follow. I can't recommend this kit enough for someone that is looking to make a space game. I just wish I had found this kit when I first found Unity 3D. Things would have been a lot easier. But then again, sometimes things happen when they are supposed to happen.

    While this is not a complete game system it really has a solid foundation to become one. Now that I got the build that has TNet and NGUI integrated I'm really loving it. I'm still learning about networking but TNet does make it much more understandable how to implement it.

    Actually with this kit it is all set to go so you really do not need to learn any thing to get it to run as long as you know how to make a build with Unity 3d. And just to be clear, the Space Game Starter Kit does multiplayer networking all on it's own. TNet and NGUI are not needed to achieve this but there just are certain things in life that makes it nicer.

    There as some great examples/features in TNet and NGUI that are helpping me to customize this kit and make the game I have wanted to make. For me this is just a hobby but it is very easy for me to see that all three of these tool sets are of a very professional quality. The support is great. If you have any doubts either way just check out his support threads. I'm looking forward to purchasing the other tool sets that he also has available.
     
  44. GregMeach

    GregMeach

    Joined:
    Dec 5, 2012
    Posts:
    249
    Hi Aren,

    Are the current kits (SGSK, NGUI and TNet) compatible with the newest (4.0) Unity? If so, do they or will they require me to purchase Unity Pro?

    Thanks
     
  45. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    No, you don't need Unity Pro, and yes they are compatible.
     
  46. GregMeach

    GregMeach

    Joined:
    Dec 5, 2012
    Posts:
    249
    Awesome and thanks for the quick reply - Have a great new year!
     
  47. Distant_Temples

    Distant_Temples

    Joined:
    Apr 14, 2012
    Posts:
    131
    Aren,
    I was thinking that I may want to change the input settings to my own labels and such. But I was also wondering why you set them up the way you did. I don't want to break any functionality so I thought I would ask why you set them up that way. Was it just a personal preference or does it have to be that way to lets say support mobile devices or something?
     
  48. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Thanks, have a great year yourself! ;)
    Personal preference, really. :p
     
  49. Distant_Temples

    Distant_Temples

    Joined:
    Apr 14, 2012
    Posts:
    131
    Good. I didn't want to get down the road and have to double back because I changed them. They do seem to confuse me a little (which isn't hard to do at times) although they are labeled well. Also when I try to add a different asset that has the default settings it starts throwing warning that freaks me out at first even thought its just the input setting. lol Doubt there is really much of a way to avoid that.

    But hey different is totally cool in my book. Kinda what I like about your kit, it allows "different" to happen easily.

    Thanks
     
  50. Kafar

    Kafar

    Joined:
    Nov 29, 2012
    Posts:
    220
    Hi all,

    Stupid question but... I need to mix the two kit, is possible? Someone already tried?
    The multiplayer feature is optional to use?
    Thanks

    -Kafar