Results 1 to 3 of 3

Thread: Physics.cast(...) return empty table if direction is not provided

  1. #1

    Physics.cast(...) return empty table if direction is not provided

    Here it says that direction is an optional parameter and when it's not provided, the cast is motionless.
    However, when direction is not provided, the cast always returns an empty table.

    This works:

    Code:
    local objectsInZone = Physics.cast({
            origin = protectedZone.getPosition(),
            direction    = {0,1,0},
            type = 3,
            size = protectedZone.getScale(),
            orientation = protectedZone.getRotation(),
            max_distance = 0
        })
    This returns empty table:

    Code:
    local objectsInZone = Physics.cast({
            origin = protectedZone.getPosition(),
            type = 3,
            size = protectedZone.getScale(),
            orientation = protectedZone.getRotation(),
        })
    max_distance was removed here as well as direction, but leaving it does not change anything. It's the direction parameter that causes the problem.

  2. #2
    It probably won't be fixed since (afaik) it's a direct API to Unity cast functions, Physics.ShpereCast in this case. In Unity, to do a "motionless sphere case" you would use Physics.OverlapSphere, but it is not exposed to us within TTS so out of luck I guess.

    Not like it really matters, since we can either limit distance like you did or (if that causes any problems) make a cast with {0, 1, 0} dir, then another with {0, -1, 0} dir and their results intersection should be a static sphere cast. I know these are workarounds but there are maaaany issues that can't be ignored that easy

  3. #3
    I'm ok with a workaround but you shouldn't have to search for it through trial and error. Either of these wouldn't be hard to do:

    - Add a warning about this to api documentation
    - Make the function itself issue a warning when direction is not provided
    - Make the workaround built-in (if direction is not provided, the function assumes [direction={1,0,0},max_distance=0]

    P.S.

    I don't really get what you mean by "It probably won't be fixed since (afaik) it's a direct API to Unity cast functions" ... "but it is not exposed to us within TTS". The developers can change any of those whenever they wish, don't they?
    Last edited by MadCake; 07-04-2019 at 06:23 PM.

Similar Threads

  1. Question Regarding Physics.cast
    By Alfredo in forum Scripting
    Replies: 4
    Last Post: 12-28-2018, 08:38 PM
  2. Replies: 2
    Last Post: 11-13-2017, 07:54 AM
  3. Physics.cast ray, debug extending past where it actually affects
    By DeathKnight in forum Scripting Bug Reports
    Replies: 1
    Last Post: 07-26-2017, 06:42 AM
  4. [ADDED] Physics.cast() should also collide with the table.
    By Mark in forum Scripting Suggestions
    Replies: 0
    Last Post: 06-11-2017, 10:11 AM
  5. Replies: 1
    Last Post: 01-27-2017, 09:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •