Jump to content

Search the Community

Showing results for tags 'raycast'.

  • 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. I'm trying to make my LaserDist mod a bit smarter about reporting the kind of thing the laser has hit: ground versus building versus scatter rock (that last one is only for mods have made the scatter rocks have colliders). The current logic is along these lines (this is a simplified version that demonstrates where I'm having a problem with a lot of the extra stuff stripped out): RaycastHit hit = bestLateUpdateHit; // bestLateUpdateHit is populated elsewhere in the mod GameObject hitObject = (hit.transform == null ? null : hit.transform.gameObject); if (hitObject != null) { CelestialBody body = hitObject.GetComponentInParent<CelestialBody>(); if (body != null) { // code that handles the case where the raycast hit terrain } else { // code that handles the case where the raycast hit something other than terrain. } } The problem is that in my testing for whether the raycast hit terrain or something else, testing for CelestialBody generates false positives because in addition to being true for terrain, it's also true for space center buildings, and every other non-vessel object. This makes sense if SQUAD has designed things so that the buildings are children of the CelestialBody just like the terrain polygons are, which of course they have to be so they can stay "glued" to the planet surface and move with it. So what I'm looking for, is what type "T", or what set of "T"'s can I use in the call GetComponentInParent<T>() that will help me distinguish "this thing is the ground" from "this thing isn't the ground"? I've been trying to find experimentally at runtime just what the full parent-chain looks like for my hits all the way up (i.e. this component is a member of this component which is a member of this component, etc) but the problem I'm having is that C# won't allow me to make type T in the various thingy.GetFoo<T>() calls be the open-ended GameObject type or Component type. It insists I use a type a bit more specific than that, and the whole point of the excercise is that I don't actually know what those types are yet and I'm trying to discover them. I haven't found in the Unity API where the call is for "just get the immediate parent, and I don't know yet what type that parent will be. I'd like to print it at runtime." So because I don't know the actual component tree layout SQUAD uses for terrain versus building meshes, and I haven't succeeded at finding that "just get me the parent" call so I can do my own investigation and learn it, I don't know how to discover what kind of thing my raycast has hit. Does anyone know which type T with GetComponentInParent<T>() will find a hit for ground but not for buildings? (or visa-versa).
×
×
  • Create New...