Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do I make raycasts ignore collisions completely?

I have this ray

And it hits everything not assigned to the layer "IgnoreRaycast"

How do I make it ignore absolutely all colliders and layers and stuff?

Best Answer

  • MouledouxMouledoux Member
    Accepted Answer

    You can just get the relative direction of the player to the cursor with things like ScreenToWorldSpace or WorldToScreenSpace, look up both of those on unity docs (I would link, but I'm on mobile rn).

    Then to get a vector (direction) from A -> B, you just subtract A from B. So the directions the mouse is from the player, Player -> Mouse, is mousePosition - playerPosition

Answers

  • you would do that with its layer mask when you call Physics.Raycast

    But, why would you want to do that? Raycast would be absolute useless if it couldn't detect anything.

  • Hey my dude, thanks for helpimg. I am a newb in programming, and thought this would be helpful to find a direction for the player to move.

    This raycast is pointing towards the cursor, so the player jumps towards where the raycast is pointing, but it doesn't eork really good, so how would you recommend I do this? (without raycasts)

  • WarpWarp Administrator

    Are you trying to have the player move where you click?

  • TheLoafDudeTheLoafDude Member
    edited June 2020

    No, I am not trying to have the player more where I click, I am trying to make the player jump towards where I click on the screen. @Warp

  • ABOABO Member
    edited June 2020

    Please mark this question as answered, because you have asked another question about the same topic in the forum above.

Sign In or Register to comment.