Godot Version
godot 4.7 (mobile)
Disclaimer
Hi guys, the other help question is till in revision! so dont worry, its just a project that im not really sure.
Question
SO im making a cozy building game. its similar to the sims.(its just a game bc i like building : D) And when the player clicks the floor it will add to the position of the mouse the wall(its all in 3D). Everythings working. im messing with the code tho and i tought that the player would like to put some windows. the problem is that i never used a CSGbox for cutting an instance (in this case a duplicated node of the scene) all bc i dont know how to modify children of instances in GDScript. Any help is appreciated!
(most is placeholder and messy TwT ask for anything of the code!) Code:
extends Node
var variable = false
var scene = load("res://idk.tscn")
var scene2 = load("res://control.tscn")
var Window_ = load("res://Window.tscn")
var Wall_Create = false
var SPEED = 1.5
var sensitivity = 0.005
const TILE_SIZE :Vector3 = Vector3(3000,0,3000)
var disabled = false
var xx = false
var xl = false
var numb = 0
var modify_wall = false
var intersection
func shoot_ray():
pass
func _process(delta: float) -> void:
if Input.is_action_just_pressed("rotate"):
%idk.rotation.y += 0.045
if Input.is_action_just_pressed("unbuild"):
%idk.hide()
disabled = true
var cam := %caamm
var mouse_pos = get_viewport().get_mouse_position()
print(mouse_pos)
var rayStart : Vector3 = cam.project_ray_origin(mouse_pos)
var direction : Vector3 = cam.project_ray_normal(mouse_pos)
var plane := Plane(Vector3.UP)
intersection = plane.intersects_ray(rayStart, direction)
print(intersection)
if intersection and variable == false:
if Wall_Create and disabled == false:
var instance = scene2.instantiate()
%VBoxContainer.add_child(instance)
var copy = %idk.duplicate()
%Node3D.add_child(copy)
if modify_wall:
instance.Container.show()
if disabled:
%idk.global_position.x = intersection.x
%idk.global_position.z = intersection.z
if !Wall_Create:
if xl:
if Input.is_action_just_pressed("t"):
xx = true
numb += 1
if numb == 2:
numb = 0
xx = false
xl = false
if xx == true:
if %idk.rotation.y == 0:
%idk.global_position.x = intersection.x
if %idk.rotation.y == 90.2:
%idk.global_position.z = intersection.z
else:
%idk.global_position.x = intersection.x
%idk.global_position.z = intersection.z
%idk.global_position.x = intersection.x
if xx == false:
%idk.global_position.x = intersection.x
%idk.global_position.z = intersection.z
%moseu.position = get_viewport().get_mouse_position()
if Input.is_action_just_pressed("create_w"):
Wall_Create = true
else:
Wall_Create = false
func _on_virtual_joystick_pressed() -> void:
variable = true
func _on_virtual_joystick_released(input_vector: Vector2) -> void:
variable = false
func _on_area_3d_mouse_entered() -> void:
xl = true
if Input.is_action_just_pressed("create_w") and disabled:
modify_wall = true
func _on_area_3d_mouse_exited() -> void:
pass # Replace with function body.
func _on_button_pressed() -> void:
variable = true
$"../../../../../Button/sASS".start()
func _on_s_ass_timeout() -> void:
variable = false