0 votes

I have been trying to create a random generation but I need a random number and when I set the position it says that:
Invalid set index 'x' (on base: 'CSGMesh') with value of type 'float'.
Here is my code:

extends Spatial
var randgenerate = RandomNumberGenerator.new()
onready var land = $CSGMesh
func _ready():
# randomize seed
rand
generate.randomize()
# generate a random float between -1 and 0
var randfloat = floor(randgenerate.randfrange(0, 100) * 10)
# print random number
land.x = rand
float

asked May 20 in Engine by Coder8188 (16 points)

1 Answer

0 votes

With land.x you're trying to set the position as though the CSGMesh is a Vector3. You need to set the land.translation.x or land.transform.origin.x, regardless if it's a float or int.

answered May 20 by Magso (2,851 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.