0 Favourites

How do I Make object Always be on cursor.

  • Guys i got a proble. I am making Sprite following cursor. For exampla evrytick-on Left Click is down-Set Sprite position Mouse.x mouse.y yes it works fine but. When i am moving my mouse in game. Mouse is faster then frame in game and that way my cursor leaving my sprite and its stop moving. How can i make my Sprite same fast as my cursor... i mean i want to make sprite stay on cursor all the time(while i am holding left click) and never leave it. Sry for bad english hope someone can help me.

  • [System] On Start of Layout

    [Mouse] Set cursor to None

    [Mouse] Set cursor from Sprite

    This will turn your cursor into the sprite, that way speed will never be an issue.

    Other useful information...

    The sprite can not have dimensions larger than 64*64 to be used as a cursor.

    The sprite set to cursor will appear as it does in the image editor, not as it does in the layout. Therefore, it will not take scaling/rotating into account.

    Also you may wish to include the action "[Sprite] Destroy" following "[Mouse] Set cursor from Sprite" as you will otherwise have a static cursor in your layout which would be an unnecessary object and look odd.

  • Mmm. thank you. maybe then is any way to make my mouse move slower in game?

  • There is no way to reduce the speed of the cursor that I am aware of, but I think I know what you need to do.

    Set the cursor to hidden, and create a helper sprite with pin behavior

    On created, pin the helper sprite to the object sprite (Position only)

    Tell the helper sprite set position (Mouse.X,Mouse.Y)

    Then, tell the object sprite to move X pixels per second at angle (HelperSprite.Angle)

    In this way, the object sprite will follow the hidden cursor at the desired speed.

    If you only want to be able to "click" on things that the object sprite is overlapping, you can add that as a condition.

  • If I knew what exactly you were trying to accomplish, I could probably offer a better example or alternative. Maybe upload a Capx and some information about what is supposed to be happening with the Mouse/Sprite?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • If you use ajabael code and the have an every tick statement you could the set and objects position to lerp it to the mouse and use dt aswell if you dont understand let me know.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,517
DMT2005's avatar
DMT2005
Unread sticky
1 Favourites
C2 Games made with CocoonIO
136 89,843
minhcuong's avatar
minhcuong
Unread hot topic
99 10,158
karshinkoff's avatar
karshinkoff