I'm trying to get this code to work and replace one object in the map that is broken with a new one that I will assign to it. but I don't know why I get this error
Assets\Replacement.cs(31,63): error CS0117: 'Quaternion' does not contain a definition for 'Indentity'
this is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Replacement : MonoBehaviour
{
public GameObject Broken_Table;
public GameObject Table;
private bool used = false;
void Start()
{
}
void Update()
{
if (!used && Input.GetKey(KeyCode.A))
{
Replace(Broken_Table, Table);
Debug.Log("Replaced");
used = true;
}
}
void Replace(GameObject obj1, GameObject obj2)
{
Instantiate(obj2, obj1.transform.position, Quaternion.indentity);
Destroy(obj1);
}
}
CodePudding user response:
This error occurs because the data type does not contain a referenced member. Quaternion.indentity should be changed to Quaternion.identity.The object is destroyed and you should re-instantiate it.
if (!used && Input.GetKey(KeyCode.A))
{
GameObject broken_Table = Instantiate(Broken_Table) as GameObject;
GameObject table = Instantiate(Table) as GameObject;
Replace(broken_Table, table);
Debug.Log("Replaced");
used = true;
}
CodePudding user response:
Try replacing "Quaternion.indentity" by "obj1.transform.rotation"