Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Assets [RELEASED] Sci-Fi Ship Controller - A versatile physics-based controller with playable demos, AI...

Discussion in 'Works In Progress' started by sstrong, Dec 7, 2018.

  1. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    I quite understand what performance overhaul will cause 1000`s of colliders\rigidbodys.
    Only way i see now - is makeing raycast\linecast projectile moving throu Transform.LookAt and Transform.Translate.
    But that will deny any pathfinding or obsticle avoidance, wich is sad.

    And it would be much simpler to experement with projectiles if they had protected restriction on fields instead of private one.
    For now will have to inherit projectile module and make one from it:)
    Also a big please to you as developers - make some generic method to translate damage value to somethig wich has no ship,cs attached to it.
     
  2. Dave_2000

    Dave_2000

    Joined:
    Oct 17, 2015
    Posts:
    51
    We already have the hitinfo data from the projectile, so we could expose that in a callback (allowing you to get the hit.point data). We could also in that callback give the prefab of the projectile template itself, allowing you to get any necessary information from the projectile for effects etc.

    Possibly we could add support for multiple damage types for projectiles - we'd probably call them Type A, Type B, Type C etc. (so that the names are generic for any project). The idea we have at the moment is that each projectile would have a damage type (e.g. Type A) and each damage region of the ship would have a specified resistance to each damage type. So if the ship had a high resistance to damage Type A and a Type A projectile hit it the ship wouldn't take much damage. Would each projectile having a single damage type be acceptable for your purposes?

    We're also looking into adding a script that you could add to any object to allow it to receive damage callbacks (so that any object could in theory receive damage).
     
  3. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    Single damage type per projectile and resistances to all damage types on a ship - is more than enough. Multiple damage types would be too complex to implement item and inventory-wise.
    That is a very good news. Glad to hear.

    And can you pretty please tell me a roadmap on seeking projectiles\missiles?)
     
  4. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Radar system now in Technical Preview

    The latest beta (available to all current customers) is now available for testing. Don't forget to backup your project first or try it in a new project. There are still a few technical glitches with the built-in radar mini-map but the Radar API should be pretty stable. Suggestions and feedback welcome.

    Included with Sci-Fi Ship Controller 1.1.2 Beta 3i

    [NEW] Ship API - SetWeaponFireDirection method added to provide easier changes at runtime
    [NEW] Auto-fire turrets can optionally check line-of-sight
    [NEW] Locations can have a Faction Id
    [NEW] Radar API (in technical preview)
    [NEW] Radar on-screen mini-map (in technical preview)
    [FIXED] PlayerInputModule - Add Events can lose connection to Input Action asset
    [FIXED] Ship AI - maxSpeed is not honoured correctly
    [FIXED] Ship AI - ship's position may become unstable after EnableShip() and velocity is reset/changed.
    [FIXED] Projectiles - when pooling is enabled, projectiles may get prematurely de-spawned
    [FIXED] DemoFlyToLocation does not check for DemoFlyToLocationShipData component
    [IMPROVED] ShipControlModule CallbackOnHit now provides hit and projectile information
     
    tgamorris76 and Silvermurk like this.
  5. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    Radar + external missile launcher script + random movement curves in missie paths.



    PS Random movement script if anyone may need:
    Code (CSharp):
    1. public class RandomMovement : MonoBehaviour {
    2.    
    3.         [SerializeField]
    4.         private Vector2 minMaxVelocity;
    5.         float currentVelocity;
    6.  
    7.         Rigidbody rBody;
    8.    
    9.         [SerializeField]
    10.         private float maxTravelTime;
    11.         float startTime;
    12.  
    13.         [SerializeField]
    14.         private float boundaryRadius;            // The radius around origin that new destinations are generated within
    15.         Vector3 destination;
    16.  
    17.         [SerializeField]
    18.         private float maxArrivalProximity;        // maximum distance to destination that is considered an arrival
    19.        
    20.    
    21.    
    22.         public void Awake()
    23.         {
    24.             rBody = GetComponent<Rigidbody>();
    25.             Vector3 spawnPos = Random.insideUnitSphere.normalized * Random.Range(0f, boundaryRadius);
    26.             transform.position = spawnPos;
    27.             destination = spawnPos;
    28.         }
    29.    
    30.         // Grab a new point in space to head toward
    31.         void GetNewDestination(){
    32.  
    33.             destination = Random.insideUnitSphere.normalized * Random.Range(0f, boundaryRadius);
    34.             currentVelocity = Random.Range(minMaxVelocity.x, minMaxVelocity.y);
    35.             startTime = Time.time;
    36.  
    37.         }
    38.  
    39.         public void Update()
    40.         {
    41.  
    42.             // Check if arrived
    43.             float distToDestination = Vector3.Distance(transform.position, destination);
    44.             bool hasArrived = (distToDestination < maxArrivalProximity) || (Time.time - startTime > maxTravelTime);
    45.  
    46.             if (hasArrived)
    47.             {
    48.                 GetNewDestination();
    49.             }
    50.    
    51.             // Rotate toward destination
    52.             Quaternion targetRotation = Quaternion.LookRotation(destination - transform.position, Vector3.up);
    53.             transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime);
    54.         }
    55.  
    56.         void FixedUpdate()
    57.         {
    58.             rBody.velocity = transform.forward * currentVelocity;
    59.         }
     
    Last edited: Feb 12, 2020
    sstrong likes this.
  6. tgamorris76

    tgamorris76

    Joined:
    Apr 24, 2013
    Posts:
    248
    How do i get it? I bought the sci fi ship controller asset
     
  7. tgamorris76

    tgamorris76

    Joined:
    Apr 24, 2013
    Posts:
    248
    Is the discord still supported at all?
     
  8. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    Get what. may i ask?)
     
  9. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Yes we're on Discord. How can we help?
     
  10. tgamorris76

    tgamorris76

    Joined:
    Apr 24, 2013
    Posts:
    248
    How do i get the new update?
     
  11. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Private msg me your name, email address and Unity invoice number. We will then add you to the beta program where you can download the latest builds as they are updated.

    BTW - We just submitted v1.1.2 to Unity for review. Typically it takes a few 1-3 days to get approved.
     
  12. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    ANNOUNCEMENT - Tech Demo Game #2

    Here is a link to our Tech Demo forum with some more information on the next Tech Demo Game we're working on.
     
  13. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    134
    Hi, quick question before I buy this: I'm looking to use it to control a drone, both in a) an automatic mode where it will be given a flight path and b) a manual mode where the player will have control of it through a first person camera and standard controls. Is this possible with this controller?
    And will you be supporting the new Unity Input system at some stage as this allows me to easily set up 2 control systems, drone and player.
    Cheers
     
  14. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    We haven't tried it with a drone yet, but I don't see why not. Our ship AI system can follow a path. We have a path editor in the asset.
    We have a dedicated Player Input Module, that attaches to a "ship" or craft. This already supports the new Unity Input System. If you do a search on this forum you'll see a few posts about it.
    You can use your own camera rig or try our Camera Module.
     
  15. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
  16. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Sci-Fi Ship Controller v1.1.2 is now in the Asset Store.

    Here are a few things we're working on for v1.1.3.
    • A Damage Receiver **
    • Custom damage types for projectiles
    • More Radar API goodness
    • Better integration with Landscape Builder
    ** You can attach this to your own non-ship gameobjects. This will work with pooled, non-pooled and DOTS projectiles. It allows you run your own custom code while receiving important information about the projectile that hit it.
     
    Silvermurk likes this.
  17. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Damage Types

    Coming in Sci-Fi Ship Controller 1.1.3 are Damage Types. Projectiles can optionally incur different damage types. Ships can react to these different damage types by calculating the amount of damage inflicted. For example, in the setup below, this ship is pretty resistant to be hit by a projectile with a Damage Type of F.

    upload_2020-2-17_10-22-9.png

    Damage types can be used with all Ship Damage Models. If you are using Localised damage, you could say configure a projectile to inflict a huge amount of damage on the ship's engines but minimal damage on other damage regions of the ship.
     
    Silvermurk likes this.
  18. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Auto Cruise

    Coming in Sci-Fi Ship Controller v1.1.3 is an auto-cruise option for the Player Input Module. This will work with all supported Input Modes. Essentially it will allow a user to approximately maintain their current forward speed without having to supply any input from their controller.

    upload_2020-2-18_9-31-51.png

    It works a little like a cruise control on a vehicle. When the ship is affected by gravity (the default configuration), the ship will still speed up if you tilt the nose down. However, if you tilt the nose up or bank left or right, more thrust will automatically be applied.
     
    tgamorris76 likes this.
  19. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    As a small enchantment for 1.1.3 - add motion prediction to turrets?:)
     
  20. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Surface Turret Module

    Coming in Sci-Fi Ship Controller v1.1.3 is a module that can be attached to free-standing turrets.

    upload_2020-2-20_17-51-19.png

    There is a simply firing mechanism (via a function call in code) or it can be configured to automatically fire at the current target.

    A simple script (Demos\Scripts\SampleSurfaceTurretAssignTarget.cs) is provided to show how easy it is to assign a target to this weapon at runtime.
     
    Silvermurk likes this.
  21. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    Sorry for being inactive - lost a week of work with dead SSD drive, downloaded latest beta of SSC,
    Rebuilding now:)
     
  22. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    In Sci-Fi Ship Controller v1.1.3 we are making it easier to detect friend or foe using the Radar API. Here is an example of a simple query.
    Code (CSharp):
    1. // Set up a query to get all enemy within a 2km radius of the player ship
    2. sscRadarQuery = new SSCRadarQuery()
    3. {
    4.     // The centre position should be updated each time the query is run
    5.     centrePosition = player1Ship.shipInstance.TransformPosition,
    6.     factionId = -1,
    7.     // exclude neutral items (0), and anything in the same alliance as the player
    8.     factionsToExclude = new int[] { 0, player1Ship.shipInstance.factionId },
    9.     is3DQueryEnabled = true,
    10.     // return the closest enemy first
    11.     querySortOrder = SSCRadarQuery.QuerySortOrder.DistanceAsc3D,
    12.     range = 2000
    13. };
     
  23. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    134
    Hi, I'm us the Controller to automate a drone that has a set height (can vary according to mission type) above the terrain. It works fine with a bit of fine tuning but is a bit sensitive to height changes and objects ahead. I wondered if it would be possible to have it read the terrain at a certain distance a head to allow a smoother flight path. And at the moment it doesn't see a cliff until too late. Hope that makes sense
     
  24. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Yes, that makes sense. We did introduce some terrain averaging in a previous version (Ground Normal Calc = Smoothed Normal). There is also a Ground Normal History settings. I'm assuming you are using these. The look ahead idea is an interesting one. It might be a little difficult (and performance expensive) to predict the path but we'll have a look and see what is possible.

    Are you using the Player Input Module, Ship AI module or your own shipinput? If you are using Ship AI you could possibly use Obstacle Avoidance for the cliff problem.
     
  25. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    134
    Thanks for the response. I've played around with most of the settings and have something close but not quite there. I was thinking of a raycast ahead at a user defined angle to detect up coming heights (and then smooth them out) and also one dead ahead for collision detection though some sort of collider interaction might work. Might be a bit tricky if the height decreases.
    I'm currently using your Player Input component with Unity's new Input system. I'll have a look at the Ship AI also. I need both as there is an option for a player to switch between automated tasks and manual control.
     
  26. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Ok. We haven't tested the scenario where a human player ship can also be an AI ship - typically they are one or the other. We might need to have some way of disabling or pausing one while the other is in use.

    With our Radar API (not sure if you're using that or not), we do check to see if this is a player ship OR a AI ship. So, we might need to take a look at that in your scenario if you want to have a dual purpose (human) player AND AI on the same ShipControlModule.
     
  27. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    A simple Projectile-To=Missile solution for SSC while it is still unimplemented *sadface*, any news on that?

    As alweys a VERY resource unfriendly implementation (a placeholder) but will autotrack to target by the shortest curve.
    Modify ProjectileModule(or inherit it in own projectile module) and change line 160 from:
    Code (CSharp):
    1. thisFramePosition = lastFramePosition + (velocity * Time.deltaTime);
    To(Increase\decrease 1.0f dampening to make it turn faster or slower) :
    Code (CSharp):
    1.  
    2.                 var enemy = GameObject.FindGameObjectWithTag("Enemy").transform;
    3.                 var rotation = Quaternion.LookRotation(enemy.position - transform.position);
    4.                 transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 1.0f);
    5.  
    6.                 // Move the projectile according to its current velocity
    7.                 thisFramePosition = lastFramePosition + (transform.rotation * velocity * Time.deltaTime);
    8.  
    Maybe you could make private fields in ProjectileMoule into sealed ones so inheriting from it wouldn`t require protection changes?:)
     
    Last edited: Feb 21, 2020
  28. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    UPD:
    Also i found a way to shoot exotic (other asset) projectiles using SSC projectile system:
    Override Inisitlize and FixedUpdate methods (and disable them completly by deleteing base. directives).
    Set UsePooling bool to false.
    Add scripts as needed to the "hulk" of a projectile.
    This allows use SSC projectile instantiator\firepoint\ammo system with any other asset you see fit without the need to add self-created launchers and make a ton of bridge scripts to communicate between them all.
     
    Last edited: Feb 21, 2020
  29. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    Also some built-in shield regeneration would feel nice )
     
  30. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Thanks for that. The reason why we may seem a little "slow" to implement some of these things is that behind the scenes we're working hard on some high performance foundational features.

    For example, an auto-targeting beta for surface and ship-based turrets is coming this week.
     
    Silvermurk likes this.
  31. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    You could just update the following in a script using whatever formula you like for regeneration.
    Code (CSharp):
    1. // calculate newShield / Health value
    2. // then apply it
    3.  
    4. shipControlModule.shipInstance.mainDamageRegion.Health = newHealth;
    5. shipControlModule.shipInstance.mainDamageRegion.ShieldHealth = newShieldHealth;
    6.  
    7. if (shipControlModule.shipInstance.shipDamageModel == Ship.ShipDamageModel.Localised)
    8. {
    9.     // loop though shipControlModule.shipInstance.localisedDamageRegionList
    10. }
     
  32. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    If you remove target finding each frame - it will be fast.
    But that`ll require more complex changes that won`t fit in a forum post.
    So decided to publish a easyer one that is easyer to understand\implement)

    Will do - for now using external one:
    Shield regenerator for SSC:
    Code (CSharp):
    1. using SciFiShipController;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class ShieldRegenerationHelper : MonoBehaviour
    7. {
    8.     public float ShieldDelay = 2f;
    9.     public float ShieldPerSecond = 1f;
    10.     private float LastDamage;
    11.     private ShipControlModule shipControlModule;
    12.  
    13.     private void Awake()
    14.     {
    15.         shipControlModule = GetComponent<ShipControlModule>();
    16.         shipControlModule.shipInstance.callbackOnDamage += ShipDamaged;
    17.     }
    18.  
    19.     private void ShipDamaged(float mainDamageRegionHealth)
    20.     {
    21.         LastDamage = Time.time;
    22.     }
    23.  
    24.     private void Update()
    25.     {
    26.         if (shipControlModule.shipInstance.localisedDamageRegionList.Count > 0
    27.             && CanRecharge())
    28.         {
    29.             foreach (var r in shipControlModule.shipInstance.localisedDamageRegionList)
    30.             {
    31.                 if (r.ShieldHealth < r.shieldingAmount)
    32.                 {
    33.                     r.ShieldHealth += ShieldPerSecond * Time.deltaTime;
    34.                 }
    35.             }
    36.         }
    37.         else
    38.         {
    39.             if (shipControlModule.shipInstance.mainDamageRegion.ShieldHealth
    40.                 < shipControlModule.shipInstance.mainDamageRegion.shieldingAmount
    41.                 && CanRecharge())
    42.             {
    43.                 shipControlModule.shipInstance.mainDamageRegion.ShieldHealth += ShieldPerSecond * Time.deltaTime;
    44.             }
    45.         }
    46.     }
    47.  
    48.     private bool CanRecharge()
    49.     {
    50.         if (LastDamage + ShieldDelay < Time.time)
    51.         {
    52.             return true;
    53.         }
    54.         else
    55.         {
    56.             return false;
    57.         }
    58.  
    59.     }
    60. }
    61.  
     
    sstrong likes this.
  33. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    I hope you won`t make a total overhaul of ship and projectilemodule sc scructure?
    I will need to modify it pretty hard after 1,1,3 release for asset cointegration:)
     
  34. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Our intention (with all our assets) is to be backward compatible this includes:
    • Public API methods
    • Public variables with comments
    Anything marked [INTERNAL ONLY] should be avoided. Speak to us if you have a requirement around any of these. Often there is another (safe) way of updating these.

    Things like private or internal variables could change without notice (although rarely do). Internal or private methods regularly get updated.
     
  35. Dave_2000

    Dave_2000

    Joined:
    Oct 17, 2015
    Posts:
    51
    We've just finished work on a feature that should do what you want - it will be in version 1.1.3. There will be a new option to enable "look ahead" which essentially allows the ship to cast rays ahead of it to check for obstacles and attempt to fly over them. As well as that, we've added a number of other improvements to the stick to ground surface feature set:
    - Now there is an option to control the damping of the ship's up/down movement (previously it was connected to the responsiveness parameter). This should help for achieving a more natural look and/or reducing overshoot
    - Tilting the ship now doesn't change the direction the ground check raycast goes in, leading to more stability while tilting the ship left/right/forwards/backwards
    - Responsiveness/damping are now tied to the difference between min, max and target distances (when use ground smoothing is enabled). This should improve behaviour when using much larger or smaller height ranges
     
  36. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    134
    That sounds perfect. Awesome response to client requests, some other Asset Store authors should take note of the customer service. I'll be checking out your other assets on the store. Thanks again and I'll give you some feedback and a review when it's available.
    Cheers
    Chris
     
    sstrong likes this.
  37. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    At the moment i need two things:
    Critical hits (ones that do multiplyed damage) and damage seperation (say TypeA does 120% damage to shield and 80% to health).
    Both require to edit base ship\projectile files.

    UPD - plus for missile weapons lock range\time are needed.
     
    Last edited: Feb 25, 2020
  38. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Guided Projectiles

    Coming in Sci-Fi Ship Controller v1.1.3 is the option to have projectiles lock onto a target.

    upload_2020-2-27_11-37-29.png

    You will have the option (in code) to override our projectile guidance system and write your own guidance code. It's easy to set up too.
    Code (CSharp):
    1. SSCManager.GetOrCreateManager().callbackProjectileMoveTo = MyCustomGuideToTargetMethod;
     
  39. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    The latest beta (1.1.3 beta 4h) includes the following:

    [NEW] Projectile Damage types
    [NEW] Damage Receiver for custom non-ship objects
    [NEW] PlayerInputModule - Auto Cruise option
    [NEW] PlayerInputModule API - EnableInput(), DisableInput(), and ResetInput() methods
    [NEW] Surface Turret Module - add free standing weapons to your scene
    [NEW] Guided Projectiles - turrets can fire projectiles that lock on to their targets
    [NEW] Stick to Ground Surface - Look ahead option to help detect obstacles ahead of the ship
    [FIXED] Radar - IndexOutOfRangeException: Array index is out of range on screen resize
    [FIXED] Localised Damage Region - ArgumentOutOfRangeException on destroy when no effects object
    [FIXED] Localised Damage Region may not be hit by a projectile if the collider is same size as the region
    [IMPROVED] (F)ind button to select a thruster, wing, control surface, damage region or weapon in scene
    [IMPROVED] Ship turret weapons - Relative Position is set when the Pivot Y transform is set
    [IMPROVED] Radar API - factionsToExclude query option for faster friend or foe elimination
     
  40. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Runtime and AI.

    Here are some of the things you can do at runtime with Sci-Fi Ship Controller.
    • Spawn Non-Player-Character (NPC) friendly or enemy ships
    • Move NPC ships with our built-in Ship Artificial Intelligence (AI) system
    • Move NPC ships with your own AI code
    • Set targets for turret weapons on ships
    • Update game scoring whenever a ship is destroyed
    • Fire weapons automatically from code
    • Change the behaviour of a ship as it enters, exits a planet’s atmosphere
    • Enable or disable “Stick To Surface” in code
    • Prevent weapons from firing during certain gameplay
    • Assign or unassign a ship from a squadron
    • Run queries against the Radar API
    • Assign targets to turret weapons and/or AI ships using the radar data.
    • Get an AI ship to follow a path
     
  41. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Sci-Fi Ship Controller v1.1.3 is now available in the Asset Store.
     
  42. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    15
    How would one go about accessing the "PlayerInputModule API - EnableInput(), DisableInput(), and ResetInput()" methods?

    Edit:
    I may have figured this out.
    Code (CSharp):
    1. using SciFiShipController;
    2. ...
    3. PlayerInputModule playerInputModule;
    4. ...
    5. void Start() {
    6.     playerInputModule.EnableInput();
    7. }
    8.  
    I noticed that I had problems if the EnableInput() was used anywhere earlier than on Start() (example: OnEnable() ) if I had more than 1 script referencing the PlayerInputModule. Is that expected?

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. SciFiShipController.PlayerInputModule.ResetInput () (at Assets/SCSM/SciFiShipController/Scripts/Control/PlayerInputModule.cs:2466)
    3. SciFiShipController.PlayerInputModule.DisableInput () (at Assets/SCSM/SciFiShipController/Scripts/Control/PlayerInputModule.cs:2457)
    4. PassengerExitTaxiState.OnEnable () (at Assets/Scripts/Passengers/PassengerExitTaxiState.cs:25)
    5.  
    I know that my PassengerExitTaxiState.cs does indeed reference PlayerInputModule correctly as I can make a copy of my GO and then the error starts occurring. This does not happen when only 1 of my GOs reference PlayerInputModule.EnableInput().
     
    Last edited: Mar 7, 2020
  43. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    Here is a quick code snippet.
    Code (CSharp):
    1. using UnityEngine;
    2. using SciFiShipController;
    3.  
    4. public class test1 : MonoBehaviour
    5. {
    6.     public ShipControlModule player1Ship;
    7.  
    8.     private PlayerInputModule player1InputModule;
    9.  
    10.     // Use this for initialization
    11.     void Start ()
    12.     {
    13.         // Typically you'll have some reference to the player ship
    14.         if (player1Ship != null)
    15.         {
    16.             player1InputModule = player1Ship.GetComponent<PlayerInputModule>();
    17.  
    18.             if (player1InputModule != null)
    19.             {
    20.                 player1InputModule.DisableInput();
    21.             }
    22.         }
    23.     }
    24. }
     
    cassius likes this.
  44. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    Can you add an inaccuracy for weapons? Like a random.inunitsphere *vecror?)
     
  45. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    For turrets?
     
  46. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    15
    Thanks for the code snippet @sstrong Glad to see I was on the right path. I noticed you used "player1Ship" and "player1InputModule" as variable names. Does SciFi Ship Controller support multiple players?
     
  47. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    We've tried to create all our modules to be multi-player friendly. We haven't specifically added multi-player support but we don't see why this wouldn't work if you need it. Should you have any issues, we're happy to look at them.
     
  48. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    This is a script order execution issue. We try very hard NOT to force our code to run in any particular order. We think the developer should control this as much as possible. Essentially Unity is running your Awake statement before ours. In the next release we'll add a test for this scenario to alert you (and avoid the error) but it will mean the method just won't run before our code is initialised.
     
  49. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    162
    For both turrets and fixed weapons i supose.
     
  50. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    1,369
    We've added a weapon (turret) inaccuracy option. We have also improved the precision of turrets. To use your own inaccuracy code with fixed weapons, it is still possible to modify the world-space target position and set the fire direction using:
    Code (CSharp):
    1. shipControlModule.shipInstance.SetWeaponFireDirection(weaponIdx, wsTargetPosition);
     
    docsavage and Silvermurk like this.
unityunity