Jump to content

Search the Community

Showing results for tags 'primitive'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements
    • Welcome Aboard
  • Kerbal Space Program 2
    • KSP2 Dev Updates
    • KSP2 Discussion
    • KSP2 Suggestions and Development Discussion
    • Challenges & Mission Ideas
    • The KSP2 Spacecraft Exchange
    • Mission Reports
    • KSP2 Prelaunch Archive
  • Kerbal Space Program 2 Gameplay & Technical Support
    • KSP2 Gameplay Questions and Tutorials
    • KSP2 Technical Support (PC, unmodded installs)
    • KSP2 Technical Support (PC, modded installs)
  • Kerbal Space Program 2 Mods
    • KSP2 Mod Discussions
    • KSP2 Mod Releases
    • KSP2 Mod Development
  • Kerbal Space Program 1
    • KSP1 The Daily Kerbal
    • KSP1 Discussion
    • KSP1 Suggestions & Development Discussion
    • KSP1 Challenges & Mission ideas
    • KSP1 The Spacecraft Exchange
    • KSP1 Mission Reports
    • KSP1 Gameplay and Technical Support
    • KSP1 Mods
    • KSP1 Expansions
  • Community
    • Science & Spaceflight
    • Kerbal Network
    • The Lounge
    • KSP Fan Works
  • International
    • International
  • KerbalEDU
    • KerbalEDU
    • KerbalEDU Website

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Skype


Twitter


About me


Location


Interests

Found 1 result

  1. Hi! I'm trying to display a simple sphere primitive (from GameObject.CreatePrimitive(PrimitiveType.Sphere) ) centered around a vessel in the tracking station, but to no avail... No fancy stuff, for a start I'd like the sphere to be a simple solid color. Problem is I even don't know if the sphere is displayed somewhere but can't be seen or if it's not displayed at all. Below is a minimal repro code for this problem: using System; using System.Collections.Generic; using UnityEngine; namespace TestPrimitive { [KSPAddon(KSPAddon.Startup.TrackingStation, false)] public class TestPrimitive : MonoBehaviour { GameObject m_SphereObj; List<Vessel> m_vesselList; bool m_inTrackingStation; bool m_isVesselFecthed; Vessel m_currentVessel; void Start() { // we want to do something only in the tracking station if (HighLogic.LoadedScene != GameScenes.TRACKSTATION) return; // Create a sphere object m_SphereObj = GameObject.CreatePrimitive(PrimitiveType.Sphere); m_SphereObj.layer = 10; // disable collider for the sphere var collider = m_SphereObj.GetComponent<Collider>(); collider.enabled = false; //Destroy(collider); // should the collider be destroyed? // get object renderer and apply attributes var renderer = m_SphereObj.GetComponent<Renderer>(); renderer.material.color = Color.red; renderer.receiveShadows = false; renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; // enable the renderer later renderer.enabled = false; } void Update() { // we want to do something only in the tracking station if (HighLogic.LoadedScene != GameScenes.TRACKSTATION) { m_inTrackingStation = false; return; } // check mapview and its camera if (!MapView.MapIsEnabled || MapView.MapCamera == null) { m_inTrackingStation = false; return; } m_inTrackingStation = true; if (!m_isVesselFecthed) { FetchVessels(); m_isVesselFecthed = true; } if (m_currentVessel != null) { // sphere parent tranform is the vessel transform m_SphereObj.transform.parent = m_currentVessel.transform; // not sure about this one... m_SphereObj.transform.position = ScaledSpace.LocalToScaledSpace(m_currentVessel.GetWorldPos3D()); // is it big enough? m_SphereObj.transform.localScale = Vector3.one * 5000f; m_SphereObj.transform.localPosition = Vector3.zero; m_SphereObj.transform.localRotation = Quaternion.identity; // enable renderer var renderer = m_SphereObj.GetComponent<Renderer>(); renderer.enabled = true; //m_SphereObj.SetActive(true); } else { var renderer = m_SphereObj.GetComponent<Renderer>(); renderer.enabled = false; //m_SphereObj.SetActive(false); } } void onVesselIconClicked(Vessel vessel) { // check vessel instance if (vessel == null) { return; } // must be in tracking station if (!m_inTrackingStation) { return; } // get currently selected vessel m_currentVessel = vessel; } void FetchVessels() { if (m_vesselList == null) { m_vesselList = new List<Vessel>(); } for (int i = 0; i < FlightGlobals.Vessels.Count; ++i) { Vessel vessel = FlightGlobals.Vessels[i]; // check that the vessel is known if (vessel.DiscoveryInfo.HaveKnowledgeAbout(DiscoveryLevels.StateVectors)) { m_vesselList.Add(vessel); } // callback called when vessel icon is clicked vessel.orbitRenderer.onVesselIconClicked.Add(new EventData<Vessel>.OnEvent(onVesselIconClicked)); } } } } Setting debug logs around all code parts I can see that all the code is executed though, which makes me wonder what is wrong. Thanks a lot for reading!
×
×
  • Create New...