Тёмный
No video :(

Easy Look At Mouse Script in Godot - Godot Quick Tips 

Code with Tom
Подписаться 13 тыс.
Просмотров 25 тыс.
50% 1

Опубликовано:

 

24 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 66   
@uheartbeast
@uheartbeast 5 лет назад
Cool series :) I look forward to more.
@CodeWithTom
@CodeWithTom 5 лет назад
Thank you so much man 😁
@popadom4529
@popadom4529 3 года назад
@HeartBeast @CodewithTom how do you look away from mouse
@reymarckessaguirre5082
@reymarckessaguirre5082 3 года назад
@@popadom4529 first, try to get the position of the mouse with get_global_mouse_position(). Then, store it in a Vector2 variable. After that, use the function var lookingAwayFrom = Vector2(get_global_mouse_position()) var lookingAt = -lookingAwayFrom func _process(delta): look_at(lookingAt)
@reymarckessaguirre5082
@reymarckessaguirre5082 3 года назад
@@popadom4529 i am not sure about my solution, but it only takes a few seconds to try, nothing much to lose.
@popadom4529
@popadom4529 3 года назад
@@reymarckessaguirre5082 Thanks
@aZaamBie135
@aZaamBie135 4 года назад
Thanks so much! I never knew it was that simple.
@CodeWithTom
@CodeWithTom 4 года назад
You're very welcome.
@malinduumeshan3119
@malinduumeshan3119 4 года назад
I switched unity to godot 2 weeks ago.I remember I wrote 4-5 lines of code to do the same thing in unity with C#
@CodeWithTom
@CodeWithTom 4 года назад
Gdscript is a very powerful and succinct language 😁
@mitchellmiller3843
@mitchellmiller3843 3 месяца назад
Exactly what I was looking for. Thank you for the quick and simple explanation!
@xyonblade
@xyonblade 4 года назад
I have been looking specifically for this for a while, forgot how to make weapons systems "look" at the mouse which might not be where the player is moving, this should help solve that problem. :D
@yourkodi3945
@yourkodi3945 4 года назад
Its crazy how this is and if you compare it to the same code in Unity, the godot version is sooo simple compared to unity version (well look at mouse code at least!)
@Goleko420
@Goleko420 4 года назад
How do you do this in 3D though? I've been trying over and over and cannot get this accomplished
@RedcodeSg
@RedcodeSg 5 лет назад
Thanks, this is really useful.
@CodeWithTom
@CodeWithTom 5 лет назад
You're very welcome 😁
@dejo095
@dejo095 4 года назад
Hey this is awesome stuff! you got yourself another subscriber buddy 😁
@lonewolfenock3527
@lonewolfenock3527 4 года назад
Simple and to the point. Subbed.
@ovaldreamx4397
@ovaldreamx4397 4 года назад
Very usefull!! Some ideas for next episodes could be shooting things, draw vectors of the body on screen and spawners
@ovaldreamx4397
@ovaldreamx4397 4 года назад
just subbed btw
@pietertalens1256
@pietertalens1256 3 года назад
Great video! I'd love to see how someone might incorporate this with an isometric sprite with 8 directions. Do you think you could make such a video?
@trakinado2564
@trakinado2564 Год назад
cool but you dont really need the func process delta in the script to it work
@champhenryduco4651
@champhenryduco4651 4 года назад
thank you please keep this up
@DexonRax
@DexonRax 3 года назад
Man you are genious
@FrancoisSchnell
@FrancoisSchnell 5 лет назад
Great serie idea, keep it up! :)
@CodeWithTom
@CodeWithTom 5 лет назад
Cheers Francois
@aamir2694
@aamir2694 3 года назад
@@CodeWithTom thank you very much
@TheTaxicomics
@TheTaxicomics 3 года назад
Thanks a bunch!
@BeSerious.studio_official
@BeSerious.studio_official 2 месяца назад
how can you do this in multiplayer?
@justash123
@justash123 3 года назад
well and thats how you create a masterpeice
@lorenzoguzzo1354
@lorenzoguzzo1354 4 года назад
great video really useful
@CodeWithTom
@CodeWithTom 4 года назад
Really glad you found it useful Lorenzo!
@xyonblade
@xyonblade 4 года назад
So here's a question, I got a scene working fine where I have a sprite looking at the mouse, but now I've instanced that scene onto a player scene three times, and now the sprite that was instanced is not looking at the mouse, I'm guessing it has something to do with only the scene being played having an active _process function? If I wanted to have multiple instances of say, a turret that are attached to the player, is it possible setting up a script or something on the original scene that then works when you instance it onto the player?
@NeZversSounds
@NeZversSounds 5 лет назад
WOW, awesome!
@Eireguy_
@Eireguy_ 3 года назад
thanik you, im making a shooter game :)
@jonus5331
@jonus5331 3 года назад
I was trying to do this by calculating vectors and using arc cos...
@diasdasilva5096
@diasdasilva5096 2 года назад
i have a sprite of a bow and i want it to look at the mouse but it never looks right: the mouse can be somewhere and the bow will be pointing elsewhere(also my game is a platformer). please help me fix it
@nhnova1452
@nhnova1452 3 года назад
thank you
@zelef2502
@zelef2502 3 года назад
I like it !
@DineshYadav-iv5jo
@DineshYadav-iv5jo 3 года назад
Thanks
@mina7572
@mina7572 4 года назад
What about launching a spawned objects in a straight line, towards the cursor?
@calebross6052
@calebross6052 4 года назад
Hey, when I do this the player looks at a position that is on the left of my mouse, instead of directly at my cursor. Do you know how to fix this?
@calebross6052
@calebross6052 4 года назад
Nvm, it was the way my sprite was facing :(
@thoaihoquang1578
@thoaihoquang1578 2 года назад
But how to get the mouse position in vector3 and Vector2 like x,y or z
@user-qc1mc2ly8j
@user-qc1mc2ly8j Год назад
My character rotates slightly away from the mouse, any idea as to why?
@00Adok00
@00Adok00 2 года назад
How can I get in an if statment that under a certain angle(when the mouse Is pointing uowards, so at the back of my player) the line has to be invisibile?
@applebeestacos4840
@applebeestacos4840 3 года назад
Can you make a Undertale/Earthbound like RPG in godot? (With gdscript)
@mistadude
@mistadude 3 года назад
Of course (sorry for the late comment)
@oghene2778
@oghene2778 2 года назад
Me over here thinking you need to use schrodinger's equation to find the superpostion of the mouse then use entropy to calculate the total efficiency of the keyboard before dividing it by 0: This guy writing 2 lines of code:
@popadom4529
@popadom4529 3 года назад
Does anyone know how to look away from the mouse?
@devinbelver7124
@devinbelver7124 3 года назад
technically you can just rotate or flip the visual so the back of the node is "looking at" the mouse
@valentas000
@valentas000 3 года назад
How to Clamp that Rotation ? Can you add Code 2 that
@beeshings
@beeshings 10 месяцев назад
Bro what?! This sh*t would take a whole afternoon to make properly in Unity... In Godot it's ONE LINE.
@JoseRoberto-wt8vz
@JoseRoberto-wt8vz 2 года назад
Muito obrigado, funcionou perfeitamente!
@mrsupertash
@mrsupertash 3 года назад
How do I change the position the sprite is facing? For example a rocket ship would be facing up when I import the asset. Do I need to import it sideways or add a rotate 90° method somewhere so that the top is facing the mouse and not the right side. What is best practice here?
@Zombozy
@Zombozy 3 года назад
Assuming you'd like the tip of your rocket to face the mouse cursor you would make it drawn horizontally, with the tip facing right. I had the same exact issue, except with a sword. Here's an example with a sword: -|========> After flipping my sprite like that, as opposed to having it straight up, it works perfectly. (hope my really cool sword picture helped)
@mrsupertash
@mrsupertash 3 года назад
@@Zombozy Thanks, the sword picture is excellent! Yeah, I mean that seems to be the intuitive workaround. I'm just wondering because I couldn't find in the Godot docs anywhere that the right side is the face. Since that is apparently what's happening, it should be stated somewhere and also why to know how to handle this best. When I look at tile sets on itch.io for example things like spaceships would be facing up, not to the right. I can't imagine the best way to handle this is to flip every single asset 90 degrees before being able to use these.
@techofhappiness395
@techofhappiness395 4 года назад
It was awesome. Can we use this code for touch screen controller ?
@CodeWithTom
@CodeWithTom 4 года назад
Good question, I haven't actually tried :)
@techofhappiness395
@techofhappiness395 4 года назад
@@CodeWithTom Try and Get Success ❤️
@interrobang9515
@interrobang9515 3 года назад
when half the video is advertising
@ClipSaam
@ClipSaam Год назад
wtfff its just!!!!
@samangolahmadi2710
@samangolahmadi2710 10 месяцев назад
1 line of code 2 mins of talking
Далее
Raycast Weapons in Godot - Make an FPS in Godot Part 2
29:00
Top Down 2D Shooting in Godot
18:33
Просмотров 83 тыс.
Cristiano ronaldo VS Tibo Inshape ! 😱😱
00:20
Просмотров 4,4 млн
I Made the Same Game in 8 Engines
12:34
Просмотров 4 млн
How to Code (almost) Any Feature
9:48
Просмотров 676 тыс.
BETTER 2D visuals in 7 EASY TIPS
10:38
Просмотров 67 тыс.
I Made My First Game in Godot in 3 Weeks...
26:21
Просмотров 316 тыс.
How To PLAN your Game as a Solo Developer
16:26
Просмотров 488 тыс.
Loops, Signals, get_node & call_deferred in GDScript
14:44
I made a game using Godot for the first time
7:35
Просмотров 1,2 млн
Cristiano ronaldo VS Tibo Inshape ! 😱😱
00:20
Просмотров 4,4 млн