Hello I need help to solve this script I do not know how to solve it because it tells me that it has

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnObject : MonoBehaviour
{

    public GameObject Foodprefab;

    public Vector3 center;
    public Vector3 size;



    // Use this for initialization
    void Start()
    {

        SpawnFood();

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Q))
            SpawnFood();

    }

    public void SpawnFood()
    {

        Vector3 pos = center + new Vector3(Ramdom.range(-size.x / 2, size.x / 2)Ramdom.range(-size.y / 2, size.z / 2));

        Instantiate(Foodprefab, pos, Quaternion.identity);
    }

    void onDrawGizmosSelected()
    {
        Gizmos.color = new Color(1, 0, 0, 0.5f);
        Gizmos.DrawCube(center, size);

    }


}

You’re missing a comma in between the parameters of your Vector3 on line 34, exactly as the error message says.

You have also misspelled “Random”.

For future posts, don’t use the poll feature if you’re not conducting a poll, and post the entire error message as text (the video link was entirely unnecessary for this question).

1 Like

in which part of the parameters of line 34 is the comma

Thank you very much I managed to solve a part of the code but it still keeps sending me the error

Post the current error in its entirety.

You can actually solve these errors yourself. If you’re just going to monkey-type random code in, every character must be spelled, capitalized, punctuated and spaced PRECISELY 100% CORRECTLY. Otherwise it won’t work.

How to understand compiler and other errors and even fix them yourself:

https://discussions.unity.com/t/824586/8

Remember: NOBODY memorizes error codes. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The important parts of an error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

1 Like