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 Problem with Raycast and Visual script.

Discussion in 'Visual Scripting' started by wasdarcade, Aug 1, 2023.

  1. wasdarcade

    wasdarcade

    Joined:
    May 17, 2023
    Posts:
    7
    Hello everyone, please help me solve the problem. I need raycast not to work on several specific objects. If I understand correctly, then I should create a layer that will contain all these objects, and then create a layer mask for this layer. Am I thinking right? If I'm right, how can I create a layer mask for this layer using visual script?
    P.S. I'm a complete newbie to Unity and programming, I'm currently trying to make a 2D game.
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    1,754
    Just create a new Layer as usual: https://docs.unity3d.com/Manual/create-layers.html

    Assign the layer to a GameObject you want the raycast to hit.

    Then choose 2D raycast node that takes LayerMask as input value and do one of these options:

    1. LayerMask Literal node + LayerMask Get Value node.
    2. AoTList Literal with one or more strings + Get Mask node that takes layerNames as input.

    EDIT: "Custom" is just a new Layer I added myself.

     
    Last edited: Aug 1, 2023
    wasdarcade likes this.
  3. wasdarcade

    wasdarcade

    Joined:
    May 17, 2023
    Posts:
    7
    Thank you very much, your answer helped me.
     
    PanthenEye likes this.