Jesusemora well.. i did not use chatGPT and i'm learning to code in C# specificaly, but thanks.
NNeOleg
- Sep 12, 2024
- Joined Sep 1, 2024
- 0 best answers
- Edited
I want to make a mechanic where you click on character and select him. The problem - i can't understand how to detect if the object is in "player" group.
public override void _Input(InputEvent @event) { if (@event is InputEventMouseButton eventMouseButton && eventMouseButton.Pressed && eventMouseButton.ButtonIndex == MouseButton.Left){ var _Rayfrom = _camera.ProjectRayOrigin(eventMouseButton.Position); var _Rayto = _Rayfrom + _camera.ProjectRayNormal(eventMouseButton.Position)*ray_l; PhysicsDirectSpaceState3D space_state = GetWorld3D().DirectSpaceState; PhysicsRayQueryParameters3D rayParams = PhysicsRayQueryParameters3D.Create(_Rayfrom, _Rayto); var rayhit = space_state.IntersectRay(rayParams); GD.Print(rayhit.Keys); GD.Print(rayhit["collider"]); //just tests if ((!rayhit.IsEmpty()) && (((Node3D)rayhit.Collider).IsInGroup("players"))){ GD.Print("lol"); } } }
The error states that "Dictionary" doesn't have "Collider" in it.
sry for bad english.