Ray-casting from the screen : Look at the mouse in 3D [GODOT]

Ray-casting from the screen : Look at the mouse in 3D [GODOT]

Nolkaloid

4 года назад

27,324 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@Gazoutx2
@Gazoutx2 - 10.12.2023 18:35

Hi! I don't know why but my character faces the opposite way from the mouse, does anyone know how to fix this?

Ответить
@khio5855
@khio5855 - 26.11.2023 18:59

For anyone trying to do this on godot 4 there are a few things you have to do differently: First you need to create a new variable called 'query' "var query = PhysicsRayQueryParameters3D.create(rayOrigin, rayEnd)" then you have to replace the var intersection shown in the video with "var intersection = space_state.intersect_ray(query)" (thanks to @rhevoramirez7969 for this) if this doesn't work or if you're getting an error that goes like "Nonexistent Function '...' in '...' " then I have no clue why but removing the rayOrigin and rayEnd variables and add "var" at the start of the rayOrigin and rayEnd In the _physics_procress() function works, and finally you have to replace "interesection.empty()" with "intersection.is_empty()"

Ответить
@Zyiah
@Zyiah - 13.07.2023 03:03

Thank you lad!

Ответить
@First_Lst
@First_Lst - 26.04.2023 00:35

What a great explanation. Great job.

Ответить
@Developers_den
@Developers_den - 07.04.2023 09:06

thank you very much i was very tired of using diffrent methods and my brain eas going to explode you saved my life you are the best

Ответить
@davidphillips9366
@davidphillips9366 - 29.03.2023 22:20

Would this work in Godot 4?

Ответить
@rhevoramirez7969
@rhevoramirez7969 - 14.03.2023 07:04

Note: in Godot 4 its necessary to construct the query to call as argument for the intersection: var query = PhysicsRayQueryParameters3D.create(RayOrigin, RayEnd); var Intersection = SpaceState.intersect_ray(query), otherwise itwill not work ;)

Ответить
@ralfbierig
@ralfbierig - 05.01.2023 03:06

Nice video. What application you use to make these animations?

Ответить
@ajpink5880
@ajpink5880 - 01.12.2022 00:55

thank you! you just made my project very nice and simple :) and the explanation was fantastic.

Ответить
@reynold99991
@reynold99991 - 30.11.2022 23:42

Lesson learned from all this. I hate 3d in godot, my project mates wanted to make a 2.5D game, everything was going okay till we reached the weapons part. We require to throw the dynamite at a flying enemy so we put the enemy in front of the player sprite ( y co-rds for enemy 8 player y is 2), when it fires using above code it stops before or after the enemy node. I just am tired maybe I am seeing shit wrong again.

Ответить
@moric4677
@moric4677 - 30.09.2022 14:43

space_state.intersect_ray(origin,end) showing error in godot 4 alpha , it says that function expects 1 argument

Ответить
@litarinn
@litarinn - 25.09.2022 11:24

is there a way to ignore player?

Ответить
@ArtembAartemb
@ArtembAartemb - 19.04.2022 23:02

Thank you, thank you, THANK YOU!

Ответить
@michkrauss
@michkrauss - 14.04.2022 12:47

Nice Tutorial - works fine but is there a way to make the camera only follow on x and y axis ?

Ответить
@yungson7869
@yungson7869 - 21.03.2022 15:14

I understand why you pass in the translation.y to the look_at function (to convert the raycast to a straight line). But why does my rig appear to point at a position above it rather than at the same height?

Ответить
@ilucasz
@ilucasz - 18.11.2021 19:16

That was a really helpful video, but I am having a problem. I did everything exactly as in the video, but for some reason my character's mesh keeps pointing to the ground in the direction that the mouse is pointing. It's my fifth time watching the video to see if I've done any mistake (no joking), but I did everything the same.

Ответить
@MadheadStardust
@MadheadStardust - 02.10.2021 01:53

It doesn't work for some reason. I did everything correct, I think. What do you have when you open RIG up. I was wondering if I need to write the code above the process_function(delta) line? thanks for the video, I just wished I could get the object to move with the mouse.

Ответить
@lorenzfk8432
@lorenzfk8432 - 17.09.2021 18:29

you're a hero

Ответить
@jimsantus8927
@jimsantus8927 - 10.09.2021 09:50

when i type + 2000 at rayend it does not work

Ответить
@regularguy3879
@regularguy3879 - 24.06.2021 22:56

whenever i point the cursor at any other mesh in my viewport, including character mesh, my character still "leans" towards it, setting the look_at argument does not work for me, any ideas ?

Ответить
@jenek0767
@jenek0767 - 15.03.2021 17:19

очень помог этот гайд. спасибо

Ответить
@davidmurphy563
@davidmurphy563 - 23.01.2021 03:38

I was doing this exact same thing and found your tutorial just after my computer bluescreened to tell me to go to bed. :)

I didn't know that camera had project ray normal. That's ideal. I was expecting to use the UV coords of the camera and its origin and try to do it manually, this is much better.

Thanks buddy.

Ответить
@misterartyparty
@misterartyparty - 11.01.2021 01:20

Yup, that was better that Godot docs, thanks a lot !

Ответить
@lflm587
@lflm587 - 21.11.2020 10:47

Everything is working but the fact that my character is flat on the ground

Ответить
@VroniastyGamingHD
@VroniastyGamingHD - 11.11.2020 22:46

Very good tutorial, helped me a lot

Ответить
@arkadiyviking3919
@arkadiyviking3919 - 09.11.2020 17:14

A collision object in the Godot has a function: _on_StaticBody_input_event(camera, event, click_position, click_normal, shape_idx).

Ответить
@ahjed7397
@ahjed7397 - 03.08.2020 13:53

Pls continue making random godot tut. Ur vids on point.

Ответить
@pand2aren
@pand2aren - 23.07.2020 09:22

hi thanks, it really helped to understand how to use raycast from camera, and look_at, have a question as im a beginner in programming in general, im thinking that i can use this raycast from camera to position characters cross-hair/cursor on ground, and make it follow mouse position. Im just stuck on "concept" how to implement it, i have interpolated camera, player node as a scene with childnode "Positiond3d" its target for interpolated camera to follow, crosshair node spatial, Should i raycast from Camera via script, and use own scripts for player node and crosshair node to change position(crosshair) and look at(player) ? im stuck accessing from player node, ray collision position. Maybe theres a better way ?
Anyway thanks for videotutorial!

Ответить
@greg7987
@greg7987 - 15.07.2020 16:24

Great great tutorial! Much thanks to you.

Ответить
@daveytrongalactus3915
@daveytrongalactus3915 - 15.07.2020 12:37

mine sais parser Error: Unexpected token: Isentifier:rayOrigin

Ответить
@TheHauntedSockdrawer
@TheHauntedSockdrawer - 06.07.2020 23:43

awesome tutorial. subbed

Ответить
@BetaTester704
@BetaTester704 - 03.06.2020 23:33

Asset Download link?

Ответить
@b3daz
@b3daz - 21.05.2020 00:24

nice.

Ответить
@JonathanDevine
@JonathanDevine - 18.05.2020 14:21

This was incredibly helpful. Thank you! Looking forward to the next video.

Ответить
@YourGalaxyInc
@YourGalaxyInc - 30.04.2020 09:28

Amazing, i helped me a lot. Thanks, good work mate.

Ответить
@psuw
@psuw - 27.04.2020 17:33

Wow. Stunning well explained! Keep that good stuff up pls!!!

Ответить