Containing mouse cursor to a circle around the hero

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • clamped means you limit the value like a combined max and min, so that you take the max between 0 and the relative position, as well as the min between 150 and the relative position.

    The actual mouse cursor will be hidden. The crosshairs will be positioned at the hero's position plus the mouse's distance from the mouse starting position (sometimes called the mouse delta), but limited to that circle.

    if the distance from the character to that offset that positions the crosshairs is going to be greater than 150, you can limit it using trig functions to keep it within that circle. there's a few ways to do this but one i was thinking of involves finding the angle between the crosshairs and the hero (like with the arctan2 function or whatever CTF uses). you can use that found angle, putting it into the cosine and sine functions to constrain it to that circle.


    Sent from my iPhone using Tapatalk

    This is my same idea, but in my last post I was not able to express it very well due to language problems, sorry. :D

  • clamped means you limit the value like a combined max and min, so that you take the max between 0 and the relative position, as well as the min between 150 and the relative position.

    The actual mouse cursor will be hidden. The crosshairs will be positioned at the hero's position plus the mouse's distance from the mouse starting position (sometimes called the mouse delta), but limited to that circle.

    if the distance from the character to that offset that positions the crosshairs is going to be greater than 150, you can limit it using trig functions to keep it within that circle. there's a few ways to do this but one i was thinking of involves finding the angle between the crosshairs and the hero (like with the arctan2 function or whatever CTF uses). you can use that found angle, putting it into the cosine and sine functions to constrain it to that circle.


    Sent from my iPhone using Tapatalk


    This is essentially what my example does. I didn't know you could limit using the mouse object, that's worth a try!

    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • For what it's worth, in my game I just made a separate control scheme for mouse and keyboard vs twin stick controller. I found it more intuitive to move the mouse freely around the screen and shoot at a specific location for mouse and keyboard controls. But maybe I am strange, haha

    I did of course hide the mouse pointer and display a little crosshair

    SUPER MEGA BEST CAT ADVENTURES Please login to see this link. and Please login to see this link. live now!

  • Please login to see this attachment.

    Threw this together in a few min. Holding - - = or + will increase/decrease radius.

    Sorry for no comments - in a hurry and have to leave soon.

    Thanks for your help, but this doesn't solve the mouse pointer/crosshair disconnect issue.

    Is this really impossible?

  • Thanks for your help, but this doesn't solve the mouse pointer/crosshair disconnect issue.

    Is this really impossible?

    I'm not on my pc so I only have the free edition of fusion. Does the mouse object not work?

    Why do you need this to be so specific? There is literally zero reason to map the windows mouse cursor.

  • I'm not on my pc so I only have the free edition of fusion. Does the mouse object not work?

    Why do you need this to be so specific? There is literally zero reason to map the windows mouse cursor.

    1. I want the crosshair to be limited as a matter of the game's difficulty and design. I want the player to have to aim their shots rather than just point and click on their targets.
    2. I need the controls to be responsive. If at any point there's a delay between the player moving the mouse and the crosshair moving the direction they've pointed the mouse, that is unresponsive and affects the basic playability of my game. If I can't get this working right, there's no point to anything else IMO.

  • 1. I want the crosshair to be limited as a matter of the game's difficulty and design. I want the player to have to aim their shots rather than just point and click on their targets.
    2. I need the controls to be responsive. If at any point there's a delay between the player moving the mouse and the crosshair moving the direction they've pointed the mouse, that is unresponsive and affects the basic playability of my game. If I can't get this working right, there's no point to anything else IMO.

    What? That makes no sense. Why would there ever be a delay? Do YOU even know what you're trying to accomplish?

    As it stands the example I gave you accomplishes exactly what you asked about - at least the way you described it.

  • What? That makes no sense. Why would there ever be a delay? Do YOU even know what you're trying to accomplish?

    As it stands the example I gave you accomplishes exactly what you asked about - at least the way you described it.

    You don't need to be rude, especially since I've explained this multiple times in detail. Perhaps this would be best described with an illustration

    Please login to see this picture.

  • The best I can interpret this is that bhlaab wants the crosshair to be an independent object that is "shoved" by the mouse position delta as opposed to orbiting it using the standard method, and limited to a circle boundary around the player at all times. Very odd; I haven't heard of any type of control like this in a game before.

    When the mouse leaves the boundary and widens the "deadzone" he's referring to, he wants the crosshair to be shoved away from the mouse as the mouse re-approaches the boundary. The problem i'm seeing with this is that you'll shove the crosshair to one side of the boundary, but then it would snap instantly back to the mouse once the mouse actually is within the boundary.

    Unless he just wants the crosshair position moved around by the mouse delta only and not defer to the mouse position when it is inside the boundary?

    Best person at writing incomprehensible posts. Edits are a regularity.

  • Here's the concept, but with a square boundary instead of a circle. It's late, so remembering the math required to make the boundary a circle is giving me a headache right now even though i'm sure it's simple X)

    I'm sure one of the other participants in the thread could modify it easily, if they so chose.

    Please login to see this attachment.

    Best person at writing incomprehensible posts. Edits are a regularity.

    Edited once, last by casleziro (January 16, 2018 at 6:00 AM).

  • Here's the concept, but with a square boundary instead of a circle. It's late, so remembering the math required to make the boundary a circle is giving me a headache right now even though i'm sure it's simple X)

    I'm sure one of the other participants in the thread could modify it easily, if they so chose.

    Please login to see this attachment.

    Yes! If I can get that in a circle it'd be perfect! Thank you.

    Another feature I'd like, and I know I'm pushing it here, but if the crosshair could track alongside the player. So if you're aiming to the left and move the player up, the crosshair goes up as well, and same for every other direction.

  • I haven't really read this forum so sorry if this has already been covered or if I'm way off the mark but this is a pretty crude version of what I think you are after. I was expecting to have to do some work to stop the cursor getting stuck to the side of the circle but actually it's not too bad as it is. It is a little bit sticky though so if you want me to smooth it out I can give it a go.

  • I haven't really read this forum so sorry if this has already been covered or if I'm way off the mark but this is a pretty crude version of what I think you are after. I was expecting to have to do some work to stop the cursor getting stuck to the side of the circle but actually it's not too bad as it is. It is a little bit sticky though so if you want me to smooth it out I can give it a go.

    This is good, thank you. I would like the stickiness fixed if you don't mind. But more importantly, is there a way to attach this crosshair to a moving object? It looks like it's soft coded to (320,240) and breaks if I try to change those values by attaching them to a moving object.

    I feel like I'm putting people through a lot here, so if someone fixes this up for me all nice I'll... I don't know, find some way to get $5 to you or something :)

  • Yeah, I'd quite like to fix the stickiness too; I'll do it when I've got a bit more time.

    As for attaching the thing to a moving object; that should be very simple. The x and y coordinates of the centre of the restricted zone are stored in a pair of alterable values in the Cursor Object. Just change the values to whatever the moving objects coordinates are each turn and things should work fine.

    Don't worry about it; I'm happy to help. I get a lot of assistance from the Clickteam community and it's nice to be able to give back when I can.

    Edit:

    Sorry, not quite as simple as I initially thought. The cursor doesn't get dragged along by the edge of the restricted zone if the zone moves beyond the cursor. Won't be too hard to fix but I don't have time now. I'll try and send you something within the next day or two.

    Edit 2:

    Wow, I must have something wrong with me; you'd already said that. I thought I'd read your post. I'll fix it soon but I definitely don't have time now.

    Edited 2 times, last by CoffeeCup (January 16, 2018 at 9:07 AM).

  • Please login to see this picture.


    Perhaps there's a quick & short solution,
    if I got it right from this picture you posted
    (sorry didn't read the whole thing so maybe I've misunderstood!)

    Please login to see this attachment.

    you can customize the max distance the cursor can travel in its alt. value "max_dist"
    (can change it in runtime too if you wish)

    a selection of my Fusion examples can be found Please login to see this link.

  • [MENTION=18866]schrodinger[/MENTION] great example! But the "orbit from center" approach isn't what bhlaab was looking for.

    I managed to shave the edges off the square and it should be working exactly as you want it right now. I added the crosshair moving along with the player: it just follows the same logic as the crosshair being moved by the mouse (add player delta to crosshair position).

    Please login to see this attachment.

    EDIT x2: Take care with the order of your events. The events from this example (minus the "start of frame" one) should go below your player movement code if you are using a custom engine, otherwise the system will break.

    Best person at writing incomprehensible posts. Edits are a regularity.

    Edited 4 times, last by casleziro: messed up first few edits (January 17, 2018 at 4:28 AM).

  • [MENTION=18866]schrodinger[/MENTION] great example! But the "orbit from center" approach isn't what bhlaab was looking for.

    I managed to shave the edges off the square and it should be working exactly as you want it right now. I added the crosshair moving along with the player: it just follows the same logic as the crosshair being moved by the mouse (add player delta to crosshair position).

    Please login to see this attachment.

    EDIT x2: Take care with the order of your events. The events from this example (minus the "start of frame" one) should go below your player movement code if you are using a custom engine, otherwise the system will break.

    This is perfect! Thank you so much!

    Do you have anything in the click store or a ~$5 game i can buy to support you back?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!