Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question I'm experiencing weird behavior with meshRenderer

Discussion in 'Editor & General Support' started by scr33ner, May 10, 2023.

  1. scr33ner

    scr33ner

    Joined:
    May 15, 2012
    Posts:
    187
    It's initially disabled & is enabled when a rayCast hits the gameObject. I can see it work in the editor but not in game mode. I'm using the same material I'm using on other objects. It's Unity 2020.3.26 URP. What's going on with this?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,768
    MeshRenderer has absolutely NOTHING to do with Raycast.

    Raycast also has absolutely NOTHING to do with Materials.

    You may wish to review what the documentation says for the particular flavor or Raycast you are using.

    Raycasting, colliders, planes, Plane, etc:

    https://forum.unity.com/threads/hel...s-are-hitting-an-object.1058393/#post-6840296

    https://forum.unity.com/threads/kee...within-the-view-frustrum.936209/#post-6117173

    And there is also EventSystem.RaycastAll for raycasting in the UI / EventSystems context.

    Raycasting in 2D:

    https://forum.unity.com/threads/ran...ear-polygon-collider-2d.1060082/#post-6851372
     
  3. scr33ner

    scr33ner

    Joined:
    May 15, 2012
    Posts:
    187
    OK... I decided to use a trigger to switch the property of the meshRender. still having the same issue with it showing only in the editor & not during game mode.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,768
    This also means nothing.

    Rather than one of us try to guess what you actually mean, please take a moment and use the correct words and terms to describe what you are doing. For instance if you mean MeshCollider then say so.

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, log output, variable values, and especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)

    You may edit your post(s) above.
     
  5. scr33ner

    scr33ner

    Joined:
    May 15, 2012
    Posts:
    187
    what do you not understand about enabling a mesh renderer when a raycast hits it?

    did you actually read the original post that said it was visible in the editor but not in game mode? and me asking WTF it's happening?

    so provide some useful insight instead of sitting on high horse & linking S*** from the manual
     
  6. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,895
    Because what you're saying still doesn't make much sense.

    Mesh Renders are not involved with collision and ray cast detection in any way; colliders are.

    Most likely the set up of your colliders is incorrect, or your code is incorrect and the raycast isn't being detected.

    You've provided zero code and zero other context so this is as much as I can infer.
     
    Kurt-Dekker likes this.