using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Cryptography;
using UnityEngine;
public class PickUpScript : MonoBehaviour
{
public float distance = 10f;
public Transform EquipPosition;
GameObject currentWeapon;
bool canGrab;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
CheckGrab();
if (canGrab)
{
if(Input.GetKeyDown(KeyCode.E))
PickUp();
}
}
private void CheckGrab()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit, distance))
{
if (hit.transform.tag == "CanGrab")
{
Debug.log("i can grab it");
currentWeapon = hit.transform.gameObject;
canGrab = true;
}
}
else
canGrab = false;
}
private void PickUp()
{
currentWeapon.transform.position = equalPosition.position;
currentWeapon.transform.parent = EquipPosition;
currentWeapon.transform.localfulerAngles = new Vector3(0f 180f 180f);
currentWeapon.GetComponent<RigiBody>().isKinematic = true;
Debug.Log("Picked It Up");
}
}
It would be really helpful if you include the full error message please. Especially the part at the end with the number (that tells you which line of code has the error).
Assets\PickUpScript.cs(41,17): error CS0104: ‘Debug’ is an ambiguous reference between ‘UnityEngine.Debug’ and ‘System.Diagnostics.Debug’
Assets\PickUpScript.cs(52,44): error CS0103: The name ‘equalPosition’ does not exist in the current context
Assets\PickUpScript.cs(54,33): error CS1061: ‘Transform’ does not contain a definition for ‘localfulerAngles’ and no accessible extension method ‘localfulerAngles’ accepting a first argument of type ‘Transform’ could be found (are you missing a using directive or an assembly reference?)
Assets\PickUpScript.cs(55,36): error CS0246: The type or namespace name ‘RigiBody’ could not be found (are you missing a using directive or an assembly reference?)
Assets\PickUpScript.cs(57,9): error CS0104: ‘Debug’ is an ambiguous reference between ‘UnityEngine.Debug’ and ‘System.Diagnostics.Debug’
For example: “Assets\PickUpScript.cs(55,36): error CS0246: The type or namespace name ‘RigiBody’ could not be found (are you missing a using directive or an assembly reference?)”
There is no such thing called “RigiBody” in Unity. There is a “Rigidbody” however. Just go through each error and make sure you’ve spelled things correctly. if you’re not sure about one, google it and you’ll find the correct spelling.
Correct names, and capitalization are important in programming. Most of your errors, as @PraetorBlue mentioned, are just typos. The error is actually pretty explicit about that. “Transform does not contain a definition for localfulerAngles”. Why? Because localfulerAngles does not exist, thus is cannot find it. Instead you meant localeulerAngles, which does exist. RigiBody does not exist, but Rigidbody does. And so on.