How do I set boundaries of objects?

I am working on a FNAF fan game here on Gdevelop.
In the game, I created this custom cursor object for the game (because it’s cool) and I put it on a separate layer above all so nothing overlaps it. But now because of that the cursor constantly goes out of bounds and detaches from the mouse when I scroll to the side.


If anyone knows a solution to this, please tell me. It would be very helpful.

Warmest Regards
-MEEEEEEEEEEEEEEEEEEEEEEE

There is action
Enforce camera boundaries

this one?

nvm, it works, thanks! but now a new problem…


You can’t tell, but the cursor sprite detached from the actual cursor. Do you have a solution for that?

I have no ideas for how to fix your issue
Maybe someone else will

But on other hand i wonder if i get what you mean

Cause you are restricting camera to NOT move too far

But cursor should not go beyond that
Then how arrow is detaching?

I understand your misunderstanding with my problem.
So the in the game I’m currently working on I have a method of scrolling using the cursor like in a Five Nights at Freddy’s game (if you have never played it then just try to see what I mean on like youtube). But because of the custom cursor, the sprite for it went out of bounds, which I have already fixed. But because of the way I coded it:
Screenshot (211)
It now detaches when I scroll to the sides, and yes, I already tried the cursor behavior, it doesn’t fix it. That’s basically the problem.

I really do not get what you mean
I mean i understand that mouse does not stick to cursor that is your issue
But i do not get when
So i cannot deduce why

Can you paste link to preview?
Like hit share button on top then publish to gd games and share the link so i can see it

Wait a sec

I am re reading your answer and did you do anything to mouse itself?
Cause you should not
You should always set it position to cursor
Like have no condition in that event
Only thing you do is restrict camera

Screenshot (211)
This is the only code I have for the cursor on the entire thing, all other code is attached towards the mouse sprite (except for like parts where you have to click something). I already tried the cursor behavior but it doesn’t make a difference.
Also I can’t attach links to my posts :((

Try CursorX() same for Y without “0”

Also if you need to specify layer then it should be CursorX(“0”, ) if your layer is called 0
If you use base layer then CursorX(“”, )

Where correct syntax is CursorX(“LayerName”, )

wait so specifying the layer isn’t required?
and if it is, do I set the layer as the layer with the custom cursor or the base layer? Just to be sure. I’m very new to Gdevelop :\

Look i am not new and for me its stupid
So i do this

CursorX() CursroY()

If it does not work as i want then

CursorX(“LayerNameOnWhichMouseIs”, ) CursroY(“LayerNameOnWhichMouseIs”, )

Ow and to be clear
You mostly don’t but this is why i say its stupid for me

For example if you have zoom 3 on base layer and zoom 0 on layer on which you have mouse

I DO NOT remember do you need to specify layer in CursorX() and Y

But then you need to apply same zoom on layer on which mouse is

Like i said most of the cases its not required
But my course of actions is

1st go with CursroX() CursorY()
If it does not work and i have mouse sprite on different layer
Then i try to apply same actions to layer on which mouse is
Like zoom and center camera (basically you copy your layer actions and in duplicates you change layer to layer on which mouse is)

And if that does not help then i specify layer in ()

I don’t get it i don’t want to learn why i don’t care what is correct answer
All i care is that following these 3 steps in that order always solves issue for me

This almost worked. It fixed the detaching thing but now the left scroll and some buttons don’t work, well they do work, but the area to click the button is off set. I think this just might be a problem with some other code I wrote down, but IDK. If you can’t solve this, it’s fine, I’ll try find another way.

Is the click button layer fixed, while the mouse layer scrolls? If it is, you’ll have to determine the offset of the mouse when it’s layer scrolls, add that to the mouse position, and then check if that point is in the button.

Update: I fixed the left scrolling, turns out I just needed to link it to the real cursor and not the custom one. Still haven’t fixed the button.

The trigger for the button’s movement isn’t connected to the cameras. If you read the problems I had, you would know that the game and scrolling. I didn’t make it connect to the camera so you actually need to get to the destination to click the button.
This is the code I have for it:

Clicking the button right when the game starts works, but once and start scrolling it just breaks for some odd reason.

I’m not sure what you mean here, but:

Are the buttons to click on the a layer that scrolls? Is the custom mouse pointer on the layer that scrolls?

I think you need same camera settings for layers in which buttons are and mouse is
So copy their actions

Like this

See even so they are separate layers
I copy their actions so they all act the same

I think the buttons are more like a UI, but I’m trying to figure out how OP is doing it.