Author Topic: Circular bound for UIdragObject?  (Read 1373 times)

dreamt1204@hotmail.com

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Circular bound for UIdragObject?
« on: October 16, 2017, 09:08:35 AM »
Hello~

How do I make a circular bound for my UIdragObject?
I found the option in inspector using Content Rect or Panel. But how do I restrict UIdragObject movement in a circular area?

If this is not possible... any quick and easy way I can make a dynamic joystick for my game?

I will be super appreciate with any help :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Circular bound for UIdragObject?
« Reply #1 on: October 19, 2017, 02:30:52 AM »
You'll need to write some code for that. Create a copy of the UIDragObject script, or edit the existing one.

Personally I wouldn't use it for an on-screen joystick. I'd write a custom script for it, as a joystick also needs to spring back to the center when released.

Something like this would be trivial to do -- custom script with an OnDrag function that moves some target sprite, keeping it within X distance of the desired center. When released, snap or SpringLerp back to center.