Box move with Right click

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Booba

Fairly new to programming, Trying to make a box move with Right Click
i know i added unncessary things to code but i was practicing, anyway

if (@event is InputEventMouseButton eventMouseButton){
		if(eventMouseButton.ButtonIndex == MouseButton.Right && eventMouseButton.Pressed){
			Vector3 RayStart  = camera3D.ProjectRayOrigin(eventMouseButton.Position);
			Vector3 RayEnd    = RayStart +camera3D.ProjectRayNormal(eventMouseButton.Position) *200;
			var TheHit    = PhysicsRayQueryParameters3D.Create(RayStart,RayEnd);
var TheResult = GetWorld3D().DirectSpaceState.IntersectRay(TheHit);
			 if(TheResult != null){
			var    collidedObject     = (Node3D)TheResult["collider"];
			var    collidedPosition   = TheResult["position"];
			string collidedObjectName = collidedObject.Name;
			if(collidedObject.HasNode("TheType") ){
			if (collidedObject.GetNode<Node>("TheType").HasMeta("Wall"))
			 GD.Print("WALL FOUND,Cannot move there");

				if(collidedObject.HasNode("Ground") ){
				if (collidedObject.GetNode<Node>("Ground").HasMeta("Walk")){
				abc = (Vector3)collidedPosition;



and i move it like this

void MovementStuff(){ box.Translate(abc); }

instead it flies off into space, okay thanks bye =]

Edited to fix forum code formatting (though, there are still some alignment issues).

jgodfrey | 2023-06-12 20:58