Results 1 to 11 of 11

Thread: Can you use setPositionSmooth() to move cards out of hands?

  1. #1

    Question Can you use setPositionSmooth() to move cards out of hands?

    When I try it bounces back into the hand, even with Fast mode. What solutions have people come up with for this other than using strict setPosition()? I want the animation effect.

  2. #2
    Eh, on second thoughts maybe move this to Scripting Bug Reports. There doesn't seem to be any way to do this.

  3. #3
    Thread Moved.

  4. #4
    Join Date
    Sep 2016
    Posts
    215
    I recently battled this and came to the conclusion that it cannot. The best workaround that I came up with is to use setPosition to move the card directly in front of the hand zone, then immediately (don't need to wait a frame) call setPositionSmooth to the actual place I want it. It's barely noticeable. Only problem is figuring out where "in front of the hand" is.
    Last edited by Sancho; 02-22-2017 at 12:34 AM.

  5. #5
    Join Date
    May 2016
    Posts
    1,072
    This is still something that could use a fix. It feels like it would be a simpler one (detecting isSmoothMoving property and disabling the ability for a hand to grab the object while it is true) but perhaps not.

  6. #6
    Join Date
    Sep 2016
    Posts
    215
    I just want to mention that the new Player.getHandTransformation() function can make it easier to do what I mentioned above.

  7. #7
    Quote Originally Posted by Sancho View Post
    I just want to mention that the new Player.getHandTransformation() function can make it easier to do what I mentioned above.
    getHandTransform() has been around since Scripting was first released. setHandTransform() is the new one.

  8. #8
    Join Date
    Jan 2014
    Posts
    985
    The old deprecated function was getPlayerHand().

  9. #9
    Join Date
    Sep 2016
    Posts
    215
    Ok I came up with a function to get around this:

    Code:
    HAND_SCALE_CONSTANT = 1.2 -- for some reason, a hand with {1,1,1} scale is not 1 unit wide in each dimension, but instead around 1.2.
    -- Move a card from the specified player's hand to the position smoothly
    -- This works by first setting the position directly in front of the hand to prevent rubber-banding, then immediately moving to the intended position
    function setPositionFromHandSmooth(obj, player_color, position)
      local handTransform = Player[player_color].getHandTransform()
      local tempPosition = obj.getPosition()
      tempPosition.x = tempPosition.x + (handTransform.scale.z * HAND_SCALE_CONSTANT / 2 + obj.getBoundsNormalized().size.z / 2) * handTransform.forward.x
      tempPosition.z = tempPosition.z + (handTransform.scale.z * HAND_SCALE_CONSTANT / 2 + obj.getBoundsNormalized().size.z / 2) * handTransform.forward.z
      obj.setPosition(tempPosition)
      obj.setPositionSmooth(position)
    end
    It's a bit hacky since the z-scale of the hand isn't at a 1:1 ratio with the size. I guessed it to be about 1.2, and it worked well for my tests.

    You could go further and check all hands for the object and using that instead of supplying it with a color. You could even make this an all-in-one replacement for setPositionSmooth by searching all hands to see if the object is present. If so, do the above, otherwise use a normal setPositionSmooth. That all seemed a bit excessive, though.
    Last edited by Sancho; 08-15-2017 at 09:37 AM.

  10. #10
    Quote Originally Posted by Knil View Post
    The old deprecated function was getPlayerHand().
    WOW! I have been looking everywhere for doc on getPlayerHand() since it is used in the Blackjack game.

  11. #11
    Join Date
    Sep 2016
    Posts
    215
    The documentation can be found here: http://berserk-games.com/knowledgebase/player/

    Though I don't know why it references the Blackjack Example, since as you said it is out of date.

Similar Threads

  1. [ADDED] [v8.7] Move object a certain distance
    By Zelc in forum Suggestions
    Replies: 7
    Last Post: 10-01-2018, 11:23 PM
  2. Replies: 2
    Last Post: 01-05-2017, 03:56 PM
  3. How do I move the bag object?
    By heyhogan in forum General Discussion
    Replies: 2
    Last Post: 07-15-2016, 02:48 PM
  4. Disable "Shared Team Hands" in the Hands menu
    By Mark in forum Suggestions
    Replies: 2
    Last Post: 05-29-2016, 08:02 AM
  5. Replies: 1
    Last Post: 06-23-2014, 05:13 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
  •