Search Unity

Space Combat Kit (VSXGames) [RELEASED]

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

  1. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    928
    The AI checks the missile module if it has a lock. That info is written into the missile module by the weapons computer module. So to check if an ITrackable is locked, you check if the radar is targeting it (selected as target) and he missile module has a lock. My apologies for being unclear: I wasn't suggesting that you use AI for the player, I suggested you use the same method as the AI for determining if the target is locked.
     
    frankadimcosta likes this.
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    928
    OK, back at my main iron. Here's a script you can drop onto the top level of your vehicle. It will collect the scripts it needs to monitor, and then tell you what the radar is tracking, and if it has a lock on that target

    Code (CSharp):
    1. using VSX.UniversalVehicleCombat;
    2.  
    3. public class radarTargetReporter : MonoBehaviour {
    4.  
    5.     public Vehicle theVehicle;
    6.     public Radar theRadar;
    7.     public Weapons theWeapons;
    8.  
    9.     bool hasRadar;
    10.     GameObject theTarget;
    11.  
    12.     // Use this for initialization
    13.     void Start () {
    14.         // put this on root level, and you don't have to initialize the publics
    15.         if (theVehicle == null) theVehicle = GetComponent<Vehicle>();
    16.         if (theRadar == null) theRadar = GetComponent<Radar>(); // or use theVehicle.Radar;      
    17.         if (theWeapons == null) theWeapons = GetComponent<Weapons>(); // or use theVehicle.Weapons
    18.         hasRadar = (theVehicle != null) && (theRadar != null) && (theWeapons != null);
    19.     }
    20.  
    21.     // Update is called once per frame
    22.     void Update () {
    23.         // report what object is currently targeted, and if we are targeting
    24.         // something, tell us if we have a lock
    25.         if (hasRadar) {
    26.             // access the radar to get our current target
    27.             MonoBehaviour theTrackable = theRadar.SelectedTarget as MonoBehaviour;
    28.             if (theTrackable != null) {
    29.                 theTarget = theTrackable.gameObject;
    30.                 // we have a target. Let's see if the weapons
    31.                 // computer has locked a missile on it. This
    32.                 // only works if we have a missile mount and
    33.                 // a weapons computer mount which locks the missile
    34.                 // go through all missile mounts and look if one of the has lock
    35.                 bool hasLock = false;
    36.                 for (int i = 0; i < theWeapons.MountedWeapons.Count; ++i) {
    37.                     // see if the mount contains a missile
    38.                     if (theWeapons.MountedWeapons[i].IsMissileModule) {
    39.                         if (theWeapons.MountedWeapons[i].MissileModule.LockState == LockState.Locked) {
    40.                             hasLock = true;
    41.                         }
    42.                     }
    43.                 }
    44.  
    45.                 if (hasLock) {
    46.                     Debug.Log("I have LOCK on " + theTarget.name);
    47.                 } else {
    48.                     Debug.Log("Tracking " + theTarget.name);
    49.                 }
    50.             }
    51.         }
    52.     }
    53. }
    54.  
     
    frankadimcosta likes this.
  3. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176

    WOW ! I love you !!!
    It is a great gift !!! TNX A LOT !
     
    Last edited: Jan 17, 2019
  4. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Very cool, thanks for doing that!

    My first impression with your user guide and mine side by side from a critical point of view, is that it's not immediately clear in mine what the ultimate purpose of each section is, whereas with yours it's very clear what the steps are leading to.

    For example the sections 'Creating a New Module' and 'Creating a New Module Mount', while very fundamental, don't look attractive as an entry point into understanding the way the kit works and getting something cool happening. Whereas 'How to set up an AI pilot in SCK that flies a ship along a patrol route' definitely does. I also like the idea of adding Notes to provide a bit more detail on specific thingss without breaking up the flow of the guide.

    I think that your format is still too zoomed out and because of this some of your explanations of specific things are probably going to be a little confusing without more detailed context, but it's very helpful in terms of demonstrating where my guide could do better. I'm going to try to create something about halfway in between and see how that goes.

    Thanks again for putting in that effort!
     
  5. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    928
    My pleasure, Billy. A Long time ago, I happened upon the manual that came with Jensen & Wirth's UCSD Pascal. It was divided into two parts: a Reference (that described what the language was with intricate details about byte alignment for variables and compiler directives), and a Tutorial (that described how to use Pascal - the 'Hello World' stuff etc.).

    Looking at your documentation I divined that you wrote the reference part, so I wote a first tutorial. :)

    I hope that it helps people get more use out of SCK.
     
    Last edited: Jan 17, 2019
    JFI66, frankadimcosta and Billy4184 like this.
  6. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    Hi !
    Little questions.
    1) Where can i set the buttons to change the HUD selected target ?
    2) Where can i change the locking process sounds ?


    TNX !!!
     
    Last edited: Jan 17, 2019
  7. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    928
    If you are using SCK standard input scripts, you'll find the targeting controls in PlyerSpaceFighterControl in the RadarControls section. The radar controls which targets are selected, not the HUD.

    Code (CSharp):
    1. void RadarControls()
    2.         {
    3.    
    4.             if (!agent.Vehicle.HasRadar)
    5.                 return;
    6.    
    7.             // Target in front
    8.             if (Input.GetKeyDown(KeyCode.U))
    9.             {
    10.                 agent.Vehicle.Radar.GetNewTarget(RadarSelectionPriority.Any, RadarSelectionMode.Front, true);
    11.             }
    12.    
    13.             // Next/previous hostile target
    14.             if (Input.GetKeyDown(KeyCode.T))
    15.             {
    16.                 if (Input.GetKey(KeyCode.LeftShift))
    17.                 {
    18.                     agent.Vehicle.Radar.GetNewTarget(RadarSelectionPriority.Hostile, RadarSelectionMode.Previous, true);
    19.                 }
    20.                 else
    21.                 {
    22.                     agent.Vehicle.Radar.GetNewTarget(RadarSelectionPriority.Hostile, RadarSelectionMode.Next, true);
    23.                 }
    24.             }
    25.  
    26.             // Next/previous non-hostile target
    27.             if (Input.GetKeyDown(KeyCode.F))
    28.             {
    29.                 if (Input.GetKey(KeyCode.LeftShift))
    30.                 {
    31.                     agent.Vehicle.Radar.GetNewTarget(RadarSelectionPriority.NonHostile, RadarSelectionMode.Previous, true);
    32.                 }
    33.                 else
    34.                 {
    35.                     agent.Vehicle.Radar.GetNewTarget(RadarSelectionPriority.NonHostile, RadarSelectionMode.Next, true);
    36.                 }
    37.             }
    38.  
    39.             // Nearest hostile target
    40.             if (Input.GetKeyDown(KeyCode.Y))
    41.             {
    42.                 agent.Vehicle.Radar.GetNewTarget(RadarSelectionPriority.Hostile, RadarSelectionMode.Nearest, true);
    43.             }
    44.  
    45.             // Nearest non-hostile target
    46.             if (Input.GetKeyDown(KeyCode.H))
    47.             {
    48.                 agent.Vehicle.Radar.GetNewTarget(RadarSelectionPriority.NonHostile, RadarSelectionMode.Nearest, true);
    49.             }
    50.  
    51.             // 3D radar zoom out
    52.             if (Input.GetKey(KeyCode.Comma))
    53.             {
    54.                 if (hudSceneManager.LoadedHUD != null)
    55.                 {
    56.                     if (hudSceneManager.LoadedHUD.HasRadar3D)
    57.                     {
    58.                         hudSceneManager.LoadedHUD.Radar3D.IncrementZoom(false);
    59.                     }
    60.                 }
    61.             }
    62.  
    63.             // 3D radar zoom in
    64.             if (Input.GetKey(KeyCode.Period))
    65.             {
    66.                 if (hudSceneManager.LoadedHUD != null)
    67.                 {
    68.                     if (hudSceneManager.LoadedHUD.HasRadar3D)
    69.                     {
    70.                         hudSceneManager.LoadedHUD.Radar3D.IncrementZoom(true);
    71.                     }
    72.                 }
    73.             }
    74.         }

    I didn't find the location where the lock sound is played - I would have expected it in the ExampleWeaponsComputer or Radar scripts, but there doesn't seem to provisions for that in neither.
     
    Billy4184 likes this.
  8. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    TNX ! I wrote my controll using this code. ALL OK !!! TNX !
     
    Billy4184 likes this.
  9. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    The locking "sound" are the audiosources "LockingAudio" and "Lockedaudio" in the prefab HUDSpaceFighter2 under HUDMessages gameobjects !!!
     
    Billy4184 likes this.
  10. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    I began to move the radar sound effects into the HUD. The HUDMessages was going to be for both text and audio 'messages', but I realize this is a bit confusing so the plan is to put all the sounds into a component named HUDAudioManager or something like that. This allows you to do a better job of managing the way that sounds play out in terms of higher priority sounds overriding lower priority ones, and just makes for a better organisation of audio.

    Let me know if you have any feedback on this idea!
     
    frankadimcosta likes this.
  11. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    79
    Hi dude! I'm using raycasts to check for collisions on a planet's surface. I have this code in the Tick method of the combat behaviour script:

    if (Pathfinding() != Vector3.zero)
    {
    steeringTarget += Pathfinding();
    Debug.Log("Evading Terrain!" + blackboard.GroupMember.name);
    }

    where Pathfinding() returns a vector3 with a value of 1, -1 or 0 in the position opposite the raycast that returned true (e.g top raycast true: Pathfinding = (0, -1, 0) ). This doesn't seem like a good way to do it though, as I think the steering target is reverted back to what it was. How would I add a new target vector to the end of a raycast that doesn't get over-written? Cheers!
     
  12. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    First of all, the way things are done in the behavior scripts I have provided is that each behavior (currently there is CombatBehavior, PatrolBehavior and ObstacleAvoidanceBehavior) writes its values into the Blackboard script, and these values are then used in the AISpaceFighterControl script to implement the steering and throttle values.

    These behaviors can overwrite eachother's values (which is not a spectacular design decision, and one of the many things that still needs to be improved about the AI) so check that the right priority is occurring in terms of overwriting values.

    Now the AISpaceFighterControl script manages which behaviors are running and in what order. If you want to add behaviors, you can modify this script to run them in particular contexts. So you can add another behavior for terrain avoidance if you like. But if it is to go in one of the behaviors that already exist, I recommend ObstacleAvoidanceBehavior since this is essentially an obstacle avoidance issue.

    So the first question, can you simply avoid terrain by keeping the vehicle above a certain height? Then I recommend making sure that the output of the ObstacleAvoidanceBehavior takes this into account.

    A bit of background on the ObstacleAvoidanceBehavior script: Its outputs (to the blackboard) are basically an obstacle avoidance direction (Vector3), and an obstacle avoidance strength (float). The strength or risk factor is used by the AISpaceFighterControl to blend the obstacle avoidance with any other behaviour that is happening.

    So if this risk factor is modified to take into account altitude above ground, and the obstacle avoidance direction blended with Vector3.up according to the altitude, then nothing else really needs to be modified to get your vehicle avoiding the ground.

    To be specific, you might go to Line 140 of the ObstacleAvoidanceBehaviour script where the obstacle avoidance strength is set, and modify it according to the altitude, and go to Line 150 of the same script to modify the obstacle avoidance direction.

    Let me know if anything requires more explanation.
     
    joshua_42 likes this.
  13. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    79
    I could get the height of the terrain in front of the ship by raycasting to the planet center from along it's direction vector (distance of the ray's starting position from ship dependent on speed). Thanks buddy!
     
    Billy4184 likes this.
  14. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Hello everyone, I hope to get the capital ship update done tomorrow. It's all working but the demo needs a bit of polish.
     
  15. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    There is a little BUG: HUD holograms project shadows on the cockpit !!!

    The gameobject Hologram under HUDHologram->SelectedTargetHologram has the mesh renderer with parameter "cast shadow" ON.
     
    Last edited: Jan 18, 2019
  16. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    79
    Hello again. I have a raycast pointing at the planet surface and have set the totalRiskFactor to 1f (I assume is the max) if the distance is below 20 metres. It also updates the obstacleAvoidanceDirection (pointing upwards). Here's the code:

    if(TerrainAvoidance() < 20f && TerrainAvoidance() != 0)
    {
    totalRiskFactor = 1f;
    Debug.Log("PULL UP!!!");
    }

    // Update blackboard data
    if (totalRiskFactor > 0.0001f)
    {
    //Update terrain avoidance direction

    if(TerrainAvoidance() < 20f && TerrainAvoidance() != 0)
    {
    blackboard.obstacleAvoidanceDirection = -PlanetDirection();
    }
    // Your unaltered code....
    }
    }

    It seems to have no effect on their suicidal tendencies, sadly.

    Edit: nevermind! Wrong float!
     
    Last edited: Jan 18, 2019
    Billy4184 likes this.
  17. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Is it working now? For clarity it's the obstacleAvoidanceStrength that needs to be modified.

    In case you're not aware of it Debug.DrawLine is very useful for visualizing things like the current avoidance direction during gameplay
     
    joshua_42 likes this.
  18. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    79
    Working much better now!
    Also, how do you recommend making turning down not an option when below a certain height?
     
    Last edited: Jan 19, 2019
  19. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Great!

    I'm not sure exactly what you mean, would you like to prevent the ship from pitching down when below a certain height? Why is it pitching down if you have the obstacle avoidance for altitude?
     
  20. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    79
    I messed around further with my values and they work perfectly! Thanks alot for your help, I really appreciate it. Next I'm going to see if I can make their anxiety levels affect how low they're willing to go. Or is the obstacle avoidance system
    affected by anxiety anyway? I will also try and match the formation's rotation to the planet surface when in atmosphere.
    Thanks again Billy.
     
  21. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    The 'anxiety levels' are something I put in the combat behavior as a way of conceptualizing why the AI would switch between attacking and evading, and to avoid random changes in behaviour without context. So the anxiety level has a lot to do with the dynamic perception of the AI's target (is it facing toward them, is it damaging them, etc). Are you looking to couple this with altitude change?
     
  22. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    928
    Hi all,

    here's an update to the unofficial SCK tutorial, a.k.a. 'answers to questions you never knew existed'. I took some time to clean up the structure of the document, and expanded on some subjects (mostly AI).

    As always, this isn't official documentation, just me writing silly stuff concerning SCK.

    Enjoy,
    -ch
     

    Attached Files:

  23. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
  24. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    A design request:
    it's possible to split ammunition damage handling code from the moving code ?
    I'd like to splt "moving" and "damaging" handling. TNX !
    I have a lot of weapons using my own code.
    For now i use this damaging code calling SCK:.

    void SCKDamage(GameObject HitGO)
    {
    HealthFixture GOHealthFixture = HitGO.GetComponent<HealthFixture>();
    if (GOHealthFixture != null)
    {
    List<float> damageByType = new List<float>();
    float length = System.Enum.GetValues(typeof(HealthType)).Length;
    for (int i = 0; i < length; ++i)
    {
    damageByType.Add(Damage);
    }
    GOHealthFixture.Damage(damageByType, this.gameObject.transform.position, null);
    }
    }
     
    Last edited: Jan 20, 2019
  25. vamky

    vamky

    Joined:
    Aug 9, 2014
    Posts:
    70
    HI, is it possible to link yaw and roll and make camera rotation independent of roll input? I am trying to make control similar to ace combat : assault horizon. You can check this YouTube link out:
     
  26. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    928
    I must be stupid, but I see no 'moving' code (i.e. code that changes an object's position or velocity. Or do you want to separate hit detection from actually damaging an object? If you want to do that, in a project we accumulated damage over 1/2 of a second, and only applied damage twice every second (this was for a network game, to make sure the server did not get too great an advantage). That requires that you buffer the damage and apply it separately from within a co-routine.
     
  27. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    Sorry i was not precise. I needed it for missilecontroller.
    Look at ExampleMissile.prefab I have my missile prefab with guidance controller. So i need only the "damaging" code. I solved using the posted code.

    My post was for a design question: separate cs for guidance, hit, damage could be a better choice ?

    PS: Where can I set the starting health of a veihicle ? I'm using the Space Fighter 1 Enemy prefab. Health.cs and the HealthFixtures have not a starting health.
     
    Last edited: Jan 20, 2019
  28. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    928
    IIRC, the health of a vehicle is the sum of all the health Generators. These are loaded by the Mounts, not the health fixtures. If you have two armor Mounts, look up the prefab they are loading. That prefab defines their Initial health, and adding all the prefabs is the total health.

    To the best of my knowledge, there are a number of caveats:
    - shields can regenerate, so if you have a hull with 1000 'hit points' and a shield with 500, total Initial health is 1500, but the shield can withstand more than 500 if it regenerates
    - if you hit a shield that can withstand 500 Points for a total of 2000 Points, that hit will currently only wipe out the shield, and not damage the underlying armor (if there is any) - at least according to my preliminary analysis
    - you cannot yet define a ship that starts with an empty (uncharged) shield that charges up to full health, nor can you yet 'supercharge' your shields for a Moment - you'll have to program these abilities yourself. I'm writing something similar right now, and will probably include it into the tutorial

    Cheers,
    -ch
     
    Last edited: Jan 21, 2019
    frankadimcosta likes this.
  29. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    928
    I think that separating out hit detection and damage processing into separate scripts/methods can be a better design for a number of reasons:

    - It makes subclassing missiles and projectiles much, much easier -- BUT may require a more complex damage handler
    - For multiplayer games, it is much easer to only have the Server do hit and damage processing if these are separate
    - If they are separate, it's easier to accumulate hits and process them at seperate points in time (e.g. once every 1/10 of a second), something that is important to balance network play.

    Then again, the way the Missile Controller is currently written, adding hit detection to the movement method is the most efficient place, and that's where I would have placed it as well.

    -ch
     
    frankadimcosta likes this.
  30. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    Another request ! It's possible to virtualize the pool manager ? I'd like to use a better pool manager asset that i have.
     
  31. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Hi, do you mean separating into different components? If so this seems like definitely a good idea.
     
    frankadimcosta likes this.
  32. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Based on the video I would recommend 'faking' this by preventing the vehicle root transform from rolling (only pitch and yaw) and directly controlling the roll by rotating the body transform (assuming that rotating the colliders doesn't mess with the rigidbody physics in some way).

    I believe something of this sort is what the game would be doing, because coupling pitch, roll and yaw all together and using physics to achieve a particular kind of movement would require a semi-automated controller that wouldn't be perfectly responsive.

    As for the camera movement, I am separating the camera controller out of the main VehicleCamera component to make it easier to create your own controllers.
     
    Last edited: Jan 21, 2019
    vamky and frankadimcosta like this.
  33. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    The Health Generator modules loaded onto the vehicle are what actually have the health values.

    If you go to Health.cs component on the vehicle, you can see which module mounts are linked to which health fixtures. Then go to the module mount and see which module is assigned to be created there.
     
    frankadimcosta likes this.
  34. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    I'll look into that, it definitely is not good to make the code dependent on a particular pool manager. What pool manager are you using and does it return an item as a gameobject?
     
    frankadimcosta likes this.
  35. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Hello everyone, I have decided to postpone the next update until next week.

    There is a functioning capital ship demo that I can send to anyone who has bought the kit on request, but I'm not going to make the update because I have had to make one too many hacks to make the capital ships work in the same architecture as the space fighters, and I am not going to send a hacky update to the store.

    The kit has good reviews so far because of how clean and organized everything is and how much effort was put in to develop a solid, flexible architecture, and I'm not about to start tacking on stuff anywhere just to make it happen.

    The foundation of the kit is quite flexible, but there are a range of smaller but important things that are not well designed for different use-cases. For example:
    • The visual effects, such as as flyby particles, damage-based camera shake etc.
    • HUD management (HUDManager.cs in particular).
    • Creating custom HUD elements such as target boxes.
    • Missile targeting with different camera controllers, and the poorly designed WeaponsComputer component.
    • AI (which is frankly the messiest part of the kit at the moment).
    I also had started (but not finished) a major update to a lot of stuff to make it easier to use (including getting rid of a lot of interfaces and some generally bad architecture, and breaking components down into smaller, easier to use components), but this was not ready so I put it on the backburner and duplicated the last asset store version to add the capital ships update, thinking it would be quicker to just make this update and then merge it with the unfinished bigger update later on. But I am finding myself working around problems that I already solved and wasting time.

    Besides all of this, I am not hitting the target at all in terms of ease of use, and the kit has gotten to the point where it needs to be solidly cleaned out and reorganized along the lines of a lot of fantastic feedback I've gotten (particularly from @csofranz who has really gone out of his way to help me understand where some of the main sticking points are).

    Since I have a week ahead that is relatively free, I am going to dedicate it to putting the kit in the best order that I can and hopefully solving a lot of people's issues at the same time. I'll keep you updated.
     
    frankadimcosta and JFI66 like this.
  36. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    I'm using the pool manager by PathologicalGames.
    http://docs.poolmanager.path-o-logical.com/
    It returns transforms.

    For example:
    Transform temp =PoolManager.Pools["DamageManager"].Spawn(Hit.FX.transform, transform.position + Hit.FXOffset, Quaternion.identity);
     
    Last edited: Jan 21, 2019
  37. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    A little bug in gameplaydemo scene ?
    The DemoManager has FriendlyGroupManager in the field Enemy Formation Manager.
     
  38. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    Yes ! Separate component (separate file cs)
     
  39. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    Another question:
    Using "in front" for Radar target selection, the radar selects friendly ships too. How can I avoid this behaviuor ?
    In battle fast targeting makes the difference !
    TNX !
     
  40. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    Now that CAPITAL ship is coming (Frigate, Corvette and so on) we need a new weapon carrier: TURRETS !!!
     
    Last edited: Jan 21, 2019
  41. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    The capital ship demo has turrets, which can already be implemented using the GimbalController component.

    Good point, targeting front should have options for hostile and non hostile.

    Cool, I'll fix it.
     
    frankadimcosta likes this.
  42. TenKHoursDev

    TenKHoursDev

    Joined:
    Nov 9, 2014
    Posts:
    1,147
    Actually the best way to achieve responsiveness and physical simulation is by rotating the transform of the rigidbody while applying forces to it. You may have to limit how quickly that occurs but I do this in my project, it does not cause lag or the physics engine to do lots of recalculations. Works like a charm! PID controller's can make things real great too!
     
  43. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    In the video, when you move the stick to the side the aircraft yaws (rotates on the y axis) with respect to world space, while rolling.

    To achieve this with physics (with forces applied to the vehicle in the local space of its own rigidbody) the player has to control a reference pointer transform and the aircraft controller has to try to orient itself with the pointer, combining local pitch, roll and yaw (since as it rolls, the turning movement along the horizon transitions from a yaw to a pitch) using a PID controller.

    I had tried something of the sort as a test for a customer who wanted very specific movement and it didn't work out well. Besides yo-yo effect from sub-optimally tuned PID (not an issue for AI but horrible for the player) the movement felt soggy and lerpy rather than being crisp and responsive, because the player wasn't controlling the ship directly.

    PID controllers are not easy to tune perfectly for a wide range of different settings. It's not hard to get something that looks good from a distance, but from the cockpit any weird stuff is very obvious.
     
    TenKHoursDev likes this.
  44. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    GREAT! GREAT ! GREAT ! TNX !
     
  45. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    WORK IN PROGRESS: Space Combat Kit in place !

    If you want take a look to this pre-alfa gameplay mission 3 demo video (10mins)
    VIDEO

    Sorry, audio 20190122-113304.JPG is a little bit low.

    PS: TNX to SCK, after 2 years, I have the components necessary to build the game i dream.
     
    Last edited: Jan 22, 2019
  46. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Looks very cool!
     
    frankadimcosta likes this.
  47. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    Making good progress so far with the update. I created a new project and started bringing scripts in one at a time, going over all of the code and making it all as simple and intuitive as possible. Here's some of the stuff I've done:
    • Finished making custom enums that you can add and remove elements to in the editor without going into code (for things like Vehicle Control Class etc). This is also very good for preventing updates from messing with all your added enum values.
    CustomEnum.png

    CustomEnum2.png
    • Got rid of the weird Engines/IVehicleController setup. Movement controllers are going to be so different for different vehicles that there's no point trying to standardize them so much, and input scripts are going to want to access them directly anyway without going through an awkward interface.
    • Instead of the IVehicleInput interface, there's InputComponent class that you can inherit from to create input scripts for different vehicles. Also multiple input scripts can be run for one vehicle, so you can break up the code into different parts.
    • Instead of delegates I am going for Unity Events as they allow you to attach functions and do more work in the inspector.
    Events.png


    • Got rid of the awkward global UVCEventManager which I feel was getting into everything and complicating things, and it was not intuitive to extend its functionality.
    Another thing going forward is that although the subsystem/module architecture is good, namely:

    • Everything the player does is through the Vehicle component.
    • Vehicles are composed of (hold references to) subsystems
    • Subsystems are composed of (hold references to) modules
    • Functionality mostly goes into modules
    • Functions to perform operations on groups of modules are implemented in the subsystem
    • Otherwise you access a module directly through its related subsystem to do something with it.
    .. there is also a need to relax the definition of what a subsystem is, i.e. TriggerGroupsManager is not quite so clearly a subsystem as Radar, but actually does the same kind of thing (collects references to modules and manages them).

    The plan is that to add your own subsystems you can extend the Vehicle component to add references to your new subsystems and then store the vehicle as an instance of the child class in your input script etc. Then updating the kit will not affect your new vehicle classes.

    Tomorrow I will be building the vehicle one 'subsystem' at a time, making sure that everything is as straightforward as possible and no unnecessary scripts and settings need to be made.
     
  48. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    A lot of good news ! But i have a dream ! A release compatible with ECS and C# job system.
    https://unity.com/unity/features/job-system-ECS
    I't a LONG TERM dream ...
     
  49. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    4,877
    I've thought about it, but until I've seen for myself if ECS has real advantages in a general sense, and becomes mainstream I'm not sure it's worth it to make this kit use it. It's a completely different way of doing things, and all the gazillions of free resources out there on the internet that people are consuming as they build their Unity games are telling how to do things the old way.

    It does interest me a lot though in terms of building busy, procedural mega-worlds, which is something I'd really like to do in a space setting.
     
    frankadimcosta likes this.
  50. frankadimcosta

    frankadimcosta

    Joined:
    Jan 14, 2015
    Posts:
    176
    I think we are all waiting for this !!! ;-)
     
unityunity