Mouse tracking within limits

0 favourites
  • 4 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • Hello everyone.

    I'm trying to make a game where you control the body of a dragon with WASD keys and her head tracking the mouse movements.

    But I'm stuck trying to make the head moving only inside a circular area around the body (neck limit).

    I found this tutorial:

    http://www.scirra.com/tutorials/127/mousemoves-1-to-1-movement]this tutorial

    which speaks about conditional mouse tracking in its last paragraphs but I don't figure how to apply it to my problem.

    Thank you in advance and sorry for my poor English.

  • I think what you are looking for is a "distance" expression restriction to the Head motions from the Neck or body of the dragon

    You could try adding an extra Condition to your Mouse events

    Use something like this

    Mouse(distance dragonheadx, dragon heady, mousex, mousey,)

    less than or equal to (the distance you want to restrict the movement to)

    then your usual events and actions

    another way is to "Physics Joint" everything in the Dragon head and neck.. and use a constant physics force that pushes the Dragon head towards the mouse POS but is restrained by the joint force...its a fine balance but it can work good

    Obviously alot of experimentation is required.

    Did that make sense?

    Ive used this technique in another game and it works fine...

    Just play around with the factors..

  • Something like this?

    If yes, capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you guys!

    mystazsea, sure it makes sense! You've helped me to understand better how this works <img src="smileys/smiley20.gif" border="0" align="middle" />

    LittleStain, that's exactly what I want! Did you make it just for showing me? That's so kind.

    Thank you both.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)