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

Discussion Changing raycast hitpoint

Discussion in 'Scripting' started by tis226, Jun 27, 2023.

  1. tis226

    tis226

    Joined:
    Feb 9, 2023
    Posts:
    7
    Is it possible to change the offset of the raycast hitpoint?

    such as mario im making it hard to play the game.

    if i get toxinated with some potion what i want is to click a different offset from what im pointing at.

    Such as if im pointing at the left upper corner of a cube collider if i get toxinated if i click that point the system would automatically make the offset of the click point to the right upper corner.

    Is it possible to do that?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    The
    Random
    class can produce a random number, including random vectors.
     
  3. tis226

    tis226

    Joined:
    Feb 9, 2023
    Posts:
    7
    Than would it be possible for the system to indicate the random hitpoint as the orginal one?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    Not sure what you mean by 'the system' but yes, you can display whatever you like.
     
  5. tis226

    tis226

    Joined:
    Feb 9, 2023
    Posts:
    7
    So what i meant was..if there is 4 square tiles each on a corner if iclicked the first one i would like to give a random offset rto the pointer and make it click the other tile.
    So even if im pointing the first one i would like the server(?) to think that im pointing the third tile
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    Yes. You can do this. Nobody here can do it for you.

    Try this simple "Can I ...?" approach:

    Imphenzia: How Did I Learn To Make Games: