Creating a Flexible Touch Screen Camera Controller In Godot | Basics With Godot

  Рет қаралды 8,727

FinePointCGI

FinePointCGI

Күн бұрын

Пікірлер: 43
@SkuriLP
@SkuriLP 5 ай бұрын
Amazing Tutorial thank you so much!
@diogohipolito560
@diogohipolito560 Жыл бұрын
I am so glad I found your channel! It has literally everything I was looking for to build android games using Godot.
@obiekt19
@obiekt19 Ай бұрын
To anyone who tries to *apply limits* to the camera: 1. Set your desired limits on the camera object in the inspector 2. In the script from this video, inside the handle_drag() function, change the line offset -= event.relative.rotated(rotation) * pan_speed to global_position -= event.relative.rotated(rotation) * pan_speed Basically, swap *offset* with *global_position* - from now on, limits will be taken into consideration. This is by design, which you can see if you hover over any of the limit properties in the inspector - offsets ignore limits! Additionally, make sure to clamp the value in case limits are exceeded, else *global_position* will increase with further panning, even if the limit doesn't seemingly move the camera visually. From my observations, you usually want to manipulate the position/global_position of the camera for your usual movement, not the offset. The offset is, as specified in the docs, "useful for looking around or camera shake animations. The offsetted camera can go past the limits [...]". To help with camera maneuvering, I highly recommend anthonyec's *Little Camera Preview* plugin, which works for both 2D and 3D cameras, and it does take limits into consideration. It allows to display and pin camera previews inside the editor, a feature that is still sadly missing from Godot. I hope this helps someone. And as usual, astounding work Mitch, I never commented on any of your videos, but you've been a huge help to me over the past year. Thank you!
@VTSfilms
@VTSfilms Ай бұрын
Dude, you are a boss! This was exactly what I was looking for. My camera seems to 'stick' a little to the edge. When I reach the limit, the camera needs a little extra convincing to get off the edge, but im super happy I can now stay inside the play area. Thank you so much!
@VTSfilms
@VTSfilms 29 күн бұрын
Hey man, I followed your advice, and I now have the following issue: In my 2d Fire emblem clone for mobile, my Camera2D is 'sticking' to the edge of the map. I have set the limit for my camera in the Limit tab, and when I did just that, I had the issue that if you swiped 3x left, the camera would stop at the edge, but you'd need to swipe 3x right before the camera would actually move right again. Now this is my current camera script, with the bottom part helping to party solve this: The camera is still 'sticking' to the edge, needing about half the screen of swiping before letting loose of the edge. I'd love some advice on how to make my camera feel better. I added this to the bottom of the code: # Clamp the new position within the set limits new_position.x = clamp(new_position.x, limit_left, limit_right) new_position.y = clamp(new_position.y, limit_top, limit_bottom) Now it doesn't stick as much (no need to swipe as much up as you did down over the edge), but it's still sticking, needing about half a screen upwards if you went to far down.
@obiekt19
@obiekt19 29 күн бұрын
@@VTSfilms Hey there, glad you found the tip helpful! I really wish I could provide you with some sort of formula, but unfortunately I don't have one. I tried to come up with one, but I couldn't. For my case, I had my scene background top-left aligned to (0, 0), so it made limits top/left easy to set. I didn't need to pan sideways, just vertically, and it turned out that I had to clamp the y value to values like 428 and 713 (which I couldn't correlate at all to my background sprite for which I set limits for). And it worked with any kind of zoom, so no problems there. Problem is, with this approach you need to figure those out for every scene that has a different background size/camera limits. So for larger games it's not a perfect solution. I only had 4 scenes, each having a background of the same size and no further plans for expansion, so (with pain) I accepted those magic numbers. Perhaps it's related to camera's bounding rect if such thing even exists? And maybe that's how those numbers come to be the perfect ones? There must be a correlation somewhere. Honestly out of pure curiosity, if you ever figure this out, please let me know! :D
@VTSfilms
@VTSfilms 29 күн бұрын
@@obiekt19 under the camera, there is a checkbox that displays the limit box. So that makes that quite easy to set that up. (also learned that after fucking around with it for an hour...) But the camera still 'sticks' to the edge if I drag over it..
@Theo_drawi
@Theo_drawi Жыл бұрын
This helped me thank you so much!!!
@guillermolmr
@guillermolmr 6 ай бұрын
Great tutorial!
@sigitsatriap6505
@sigitsatriap6505 Жыл бұрын
love it, thanks !
@hirochima26
@hirochima26 Жыл бұрын
your videos are awesome and you are awesome, you deserve a lot of respect and support :) keep up the good work
@Nonoice
@Nonoice Жыл бұрын
It would be nice to do a tutorial on encryption of a Godot export to prevent people from being able from an .exe or an .apk to recover data from a godot project and steal the code
@FinePointCGI
@FinePointCGI Жыл бұрын
I will add it to my list!
@guillermolmr
@guillermolmr 6 ай бұрын
TIP: you can make the speed constant to the speed of your finger if you divide by the zoom: offset -= event.relative.rotated(rotation)/zoom * pan_speed
@andriipopovich6704
@andriipopovich6704 Жыл бұрын
Very useful. Thank you!
@JustMobileGames
@JustMobileGames Жыл бұрын
Very helpful I am satisfied, thank you
@ProfesorRagequitlife
@ProfesorRagequitlife 10 ай бұрын
@FinePointCGI Is there a way to limit how far the camera can travel with dragging? I cant figure out a way to keep the camera from going way off the playing field, I would figure the "limits" tab in the camera inspector would do this, but the camera is plowing right through the limits like they arent even there.
@willwainwright7166
@willwainwright7166 9 ай бұрын
I figured this out last night (am no Godot expert so may be better way). Adding this here in case someone else is looking for it. I wanted to limit based off a background image size thats larger than the camera, I set the camera anchor mode to top left (so the min pan will be 0 for both x & y axis). Then I calculate the max pan by getting the background width and subtracting the viewport width / zoom; then same for height: e.g. width: var max_x_offset = background_size.x - (viewport_size.x / zoom.x) then clamp the offset: new_offset.x = clamp(new_offset.x, 0, max_x_offset)
@guillermolmr
@guillermolmr 6 ай бұрын
There is a scale and pan on project settings now.
@Necriptos
@Necriptos 7 ай бұрын
This was great but I wish it also showed how to pan and zoom at the same time
@FinePointCGI
@FinePointCGI 7 ай бұрын
You are correct I'm not sure why I didn't cover that
@damianpinto9695
@damianpinto9695 8 ай бұрын
Gracias 🙏👍
@codewithmax
@codewithmax Жыл бұрын
Thanks! But why you don’t use clamp method for zoom limit?
@FinePointCGI
@FinePointCGI Жыл бұрын
Tbh I should have I wrote this tutorial really late last night so it's very likely that I just spaced on it lol
@codewithmax
@codewithmax Жыл бұрын
@@FinePointCGI it’s very good lesson
@newtechnologystudios
@newtechnologystudios 10 ай бұрын
I'm having a little problem. I'm trying to create the same camera in a 3D scene, but I got a converted zoom (when I zoom it out, it grows on the contrary, and vice versa). Can you tell me how to fix this? Thank you for so useful tutorial.
@ibrahimbahalwan2972
@ibrahimbahalwan2972 9 ай бұрын
I also experienced the same. Did you somehow manage to find the solution?
@guillermolmr
@guillermolmr 6 ай бұрын
Why 2 current_angle? one global and one local?
@Gostyr
@Gostyr 8 ай бұрын
"touch_points" not declared in the current scope. What i have to do with this
@FinePointCGI
@FinePointCGI 8 ай бұрын
Can I get a snippet of your code so I can see what it looks like? What version of Godot are you using
@Gostyr
@Gostyr 8 ай бұрын
@@FinePointCGI i started another project theese days, and deleated last project, so i am not able to send u snippet. Anyway have a good day
@jubibi390
@jubibi390 Жыл бұрын
hello~ may i know how did you integrate your mobile and PC? I'm also making a game for mobile.
@thetoyamostudio
@thetoyamostudio 10 ай бұрын
What if we only want to drag one direction? how can we make it? Thanks Sir.
@thetoyamostudio
@thetoyamostudio 10 ай бұрын
And how can we limit our pan area?
@PHDtt
@PHDtt 11 ай бұрын
is it possible to make a tutorial for 3D scene ?
@FinePointCGI
@FinePointCGI 11 ай бұрын
That is currently on my list! If you want let me know what you need and I will be more than happy to actually build it because that's on my list to be created soon.
@PHDtt
@PHDtt 11 ай бұрын
​@@FinePointCGIthanks u 😍, i needed a 3D navigation touch system similar to sketchfab (both Orbit and First person) , and if it will be possible to switch between them it will be amazing. the problem with sketchfab is when u switch to first person, it doesn't have any touch ui for navigation. also during navigation, if camera don't cross objects (collisions) it will be awesome. thank u again .
@PHDtt
@PHDtt 8 ай бұрын
@@FinePointCGI hope to see the video soon! 🙏
@FinePointCGI
@FinePointCGI 8 ай бұрын
@@PHDtt so im thinking about this. are we looking for a 3D isometric? or 3D first person? 3D person?
@PHDtt
@PHDtt 8 ай бұрын
@@FinePointCGI Thank u, 3D person would be great, something similar to sketchfab, using gestures to pan, move, zoom and rotate around 3d objects.
@ArabGameDev
@ArabGameDev Жыл бұрын
hi @FinePointCGI' i made a shader that add light mask bcz it's removed in 4.0 can you improve it bcz it has artifacts?
@Nelcia1
@Nelcia1 9 ай бұрын
Hey, how do I add a limit on how much the camera can go? For example games like clash of clans or hay day has this boundary where camera gets stuck. I tried using the “limit” thing built in the editor. But it doesn’t work.
Building A V2 Android Plugin! Basics with Godot 4.2
33:33
FinePointCGI
Рет қаралды 1,7 М.
Creating a 3D Character Controller With Animations with Godot 4!
46:25
АЗАРТНИК 4 |СЕЗОН 2 Серия
31:45
Inter Production
Рет қаралды 1,1 МЛН
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 2 МЛН
Do you choose Inside Out 2 or The Amazing World of Gumball? 🤔
00:19
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 54 МЛН
Someone Made Pay 2 Win: The Game And Its Hilarious
14:11
MitchManix
Рет қаралды 3,2 МЛН
The Most Valuable File Format You've Never Heard Of
15:33
Acerola
Рет қаралды 422 М.
I Hacked Diablo II To Use Modern Graphics
13:16
Nathan Baggs
Рет қаралды 218 М.
I made a... wait is this even a game?
7:13
Indie Dev Lab
Рет қаралды 96 М.
Learning C++ by making a Game... in 1 Week?!
10:14
Floky
Рет қаралды 477 М.
Evolving Genetic Neural Network Optimizes Poly Bridge Problems
9:59
How Games Make VFX (Demonstrated in Godot 4)
5:46
PlayWithFurcifer
Рет қаралды 345 М.
tf2 technically has 5 stock shotguns
3:46
shounic
Рет қаралды 533 М.
The Future of Game Development
8:58
Brackeys
Рет қаралды 1,2 МЛН
Do THIS Before You Publish Your Godot Game
3:33
StayAtHomeDev
Рет қаралды 173 М.
АЗАРТНИК 4 |СЕЗОН 2 Серия
31:45
Inter Production
Рет қаралды 1,1 МЛН