Topic was automatically imported from the old Question2Answer platform.
Asked By
TheAsker
I was using some of the code from the docs. I was trying to get the location of the mouse. But when I ran the code I got an error. The error was Invalid get index ‘position’ (on base: float).
This is the code:
extends Camera
const ray_length = 10000
func _physics_process(event):
var camera = $Camera
var from = camera.project_ray_origin(event.position)
var to = from + camera.project_ray_normal(event.position) * ray_length
It has no children. It is following a KinematicBody(3D). Godot_v3.1
Numbers don’t have position properties. The parameter passed to _physics_process() is a floating point number, by default called delta. You’ve renamed it to event, but that doesn’t change the fact that it will still be a number.
If you’re talking about the tutorial here:
That code uses the _input() function and checks if it was a mouse button click before casting the ray.