Hi there
I made a scrolling with 3 objects.
- The player
- The camera (The blue thing on the screens below)
- The target (The coordinates of the mouse actually)
The camera position is relative to the target and the player position.
BUT, there's a problem. if i go with my mouse at the right of my screen, the camera will be able to go trough all the frame (yea, sorry for my (bad) english))
So i wanted to do a max radius for the camera (in pixels)
I searched for the "Max" function and i don't understand how to use it, if you want the fomula for the camera placement i can give it
Hi there, it (partially) works but i have a problem (two actually):
The Upper-Left side is not affected
but the lower-right side is affected:
And my second problem is that the range is a square, i think i can do a circle with Pi i guess, but i don't see HOW.
Anyway, thanks for helping !
EDIT here's my formulas for the camera's position
X AXIS:
Min(X("Player")+(Dist_X_Player-target*0.5), X( "Player" )+MaxRadius)
Y AXIS:
Min(Y("Player")+(Dist_Y_Player-target*0.5), Y( "Player" )+MaxRadius)
Where: "Dist_X_Player-target" & "Dist_Y_Player-target" = The distance between the player and the target (On the X/Y axis) and maxradius is the max radius (50 pixels here)
If you want to restrict the value within a range, you can use both max and min. Something like
max ( min ( x , 50 ) , -50 )
Would keep the value x restricted within the range of -50 to 50. For your coordinates, you could do
X AXIS:
Max(Min(X("Player")+(Dist_X_Player-target*0.5), X( "Player" )+MaxRadius), X( "Player" )-MaxRadius)
Y AXIS:
Max(Min(Y("Player")+(Dist_Y_Player-target*0.5), Y( "Player" )+MaxRadius), Y( "Player" )-MaxRadius)
...but this would still result in a rectangular boundary, as you're processing the restriction at the X/Y coordinate level. If, instead, you took the distance and direction from the player to the mouse, used min to restrict the distance, then used that to determine the X and Y coordinates, you could end up with a circular camera zone.
I see you're already finding the angle and distance (though it confuses me as to how you're ending up with a negative distance in the third image?), so it shouldn't be too much trouble to do.
Hey fifth, thanks for your reply, this works like a charm (i'll try a method for a circular radius, event if it looks complicated to do. like a circle radius right ?)
The reason i have negative values is for the camera placement. If i did set the value as an absolute value, it would not work in this case, because the camera would always be at the bot-right, it couldn't go to the right and go to the top (because the XPos of the camera would be lower the the XPos of the player (and same for the Y axis). I know my english isn't too good but i think you got it !