Expected indented block for property after ":"

Godot Version

4.2

Question

im trying to make this land placer work i think it doesn’t like the func _physics_process but it told me to write it that way when i was making that part of it initially so i dont know i need help im still new

var hit = RayCast2D_is_colliding():

Called when the node enters the scene tree for the first time.

func _physics_process(_delta: float) → void :
var random = randi_range(0,3)
var _here = get_viewport()
if RayCast2D_is_colliding():
print (true)
else :
if random < 0:
var _land = Vector2i(0,0)
print(0)
set_cell(_here, 0, _land)
elif random < 1:
var _land = Vector2i(1,0)
print(1)
set_cell(_here, 0, _land)
elif random < 2:
var _land = Vector2i(2,0)
print(2)
set_cell(_here, 0, _land)
elif random < 3:
var _land = Vector2i(3,0)
print(3)
set_cell(_here, 0, _land)

Make sure to paste code with proper formatting.

Do you have a function named RayCast2D_is_colliding? For a variable definition you do not need the colon at the end, only for control-flow like if or funcs

Does this line (without the colon) give you a different error?

var hit  = RayCast2D_is_colliding()

yeah it says not in base self but if i use the other type like putting it in a raycast node it says i cant use set cell

i kinda need it to be both

yeah it says not in base self but if i use the other type like putting it in a raycast node it says i cant use set cell

Sounds like you might need two scripts, or to use the raycast node as a child.

$RayCast2D.is_colliding()

yea i put ray cast inside of the world node but i had a feeling that wasn’t communicating that to it is there something i need to connect im signaling it with draw but i dont know if thats working either

i dont know what you mean by two scripts it doesn’t want to let me have more than one connected

I think to help any furthere I would need to know what your scene tree looks like. You can add a script to each node in your project.

i dont have anything yet i made several scripts in tutorials and am trying to string the principals of them together to do what i need
trying to make stepping into a void spawn one of my tiles

i know but that script would be for that node though

like i have one for world2d and one for raycast i tried having this code in either but one says i cant use setcell and the other says i cant use raycast collision

extends TileMapLayer```

``` #extends TileMapLayer

func _physics_process(_delta: float) -> void:
	if (Input.is_action_just_pressed("left_click")):
		var random = randi_range(0,6)
		var _mouse = local_to_map(get_global_mouse_position())
		if random < 0:
			var _land = Vector2i(0,0)
			print(0)
			set_cell(_mouse, 0, _land)
		elif random < 1:
			var _land = Vector2i(1,0)
			print(1)
			set_cell(_mouse, 0, _land)
		elif random < 2:
			var _land = Vector2i(2,0)
			print(2)
			set_cell(_mouse, 0, _land)  ```

it works with a click but i want to trigger it with position of non contact if that makes sense

I think you want the raycast to get the tilemaplayer by collision

if is_colliding():
    var collider := get_collider()
    if collider is TileMapLayer:
        var collision_point := get_collision_point()
        # need to do some coversion that I am not familiar with.
        collider.set_cell(collision_point, 0, _land)

okay ill try and work all this together thanks ill let ya know how it goes

no that wont really work for me since I’m trying to use collision in the reverse way like thats only able to get a position from a hit which is a place i dont need a block

if i can place with a click i should be able to use the else from a cast or collision to do the same

i think i got it trying this preload another script like you said