So to Pull up an Object is Currently the Left Mouse used in this Script.
But the Key should be something like or What do have to Change?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pickup_Object : MonoBehaviour {
public Transform pickup;
private void OnMouseDown()
{
GetComponent().isKinematic = true;
this.transform.position = pickup.position;
this.transform.parent = GameObject.Find(“FirstPersonCharacter”).transform;
}
private void OnMouseUp()
{
this.transform.parent = null;
GetComponent().isKinematic = false;
}
// Update is called once per frame
void Update() {
}
}
Use code tags when posting on the forum. Your code will probably look something like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pickup_Object : MonoBehaviour {
public Transform pickup;
private void OnMouseDown()
{
pickup();
}
private void OnMouseUp()
{
drop();
}
// Update is called once per frame
void Update() {
if (Input.GetKeyDown(KeyCode.E))
{
pickup();
}
if (Input.GetKeyDown(KeyCode.Q))
{
drop();
}
}
private void pickup()
{
GetComponent<Rigidbody>().isKinematic = true;
this.transform.position = pickup.position;
this.transform.parent = GameObject.Find("FirstPersonCharacter").transform;
}
private void drop()
{
this.transform.parent = null;
GetComponent<Rigidbody>().isKinematic = false;
}
}