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
# generate a random float between -1 and 0
var randfloat = floor(randgenerate.randfrange(0, 100) * 10)
# print random number
land.x = rand

in Engine by (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.

by (3,227 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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.