Raycast in object variable

hello, i’m new here and this is my first post, but i have a question:
i want to make like 500 cars in a topdown race car game have 2 raycast each
and i want to store the values from the raycasts in two object variables, but the raycast condition says scene variable, how do I put the results directly in the two Object variables without creating 1000 scene variables? also if i cannot do it, how i can link scene variables to object variables for each instance?

I need it to make a simple machine learning cars and 500 cars is a good number, i can go to 150 at minimum, but 2000 would be optimal for a big batch

also i don’t know a single thing about programming in javascript, and i don’t want to learn it only for this hobby right now

I don’t know about anything other but you can link your object variable with the scene variable by:
Change the variable whateverYourVariableNameIs of yourObject to Variable(yourSceneVariable)

This is not exactly linking but it does make value the same.

1 Like

thanks, i need to do a for each with a counter for each instance of the object?

Yes, you will need to use a for-each-object condition, but won’t need a counter. It’ll loop though each instance of the object on the scene.

Raycasting for 500 objects, every frame, may cause a bit of lag depending on the rig you run it on.

1 Like

but i have to make 500 scene variables anyways?

here the link to the “game” i want to implement this

it’s still basic and doesn’t work

No, if you use a for-each object loop, you’ll need just 2 scene variables. Use them in the raycast and store them into 2 object variables for each iteration.

1 Like

Damn how much CAN I be dumb, thanks a lot