Hey guys,
So before in my prototype just using basic 3d cubes I was able to implement a pick up and drop system.
However after importing final models I’ve tested my script once again.
The item appears perfectly upon entering the level however after picking up the item and dropping it, the item has suddenly halved in size for some reason, and I’m totally stumped.
I also have a small question regarding rigid bodies, when I apply a rigid body to my collectable items they just fall straight through my level even though the floor of my level is using a box collier (I had problems with the mesh collider so I just utilised the box collider :P)
Object before pick up:
Object after pick up:
My ObjectPickup script below (attached to the player):
```csharp
**using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ObjectPickup : MonoBehaviour
{
public Image bookimage;
public Image mapimage;
public Text bookweightA;
public Text bookweightS;
public Text mapweightA;
public Text mapweightS;
public static float itemweight;
bool isholding;
//float timeleft = 2;
Color visible = new Color(0f, 0f, 0f, 100f);
Color invisible = new Color(0f, 0f, 0f, 0f);
GameObject book;
GameObject map;
void Start()
{
book = GameObject.FindGameObjectWithTag("book");
map = GameObject.FindGameObjectWithTag("map");
//anim = GetComponent<Animator>();
}
void Update()
{
if (Input.GetKey("q") && isholding == true)
{
DropItem();
}
}
void OnTriggerStay(Collider other)
{
// If the entering collider is a book...
if (other.gameObject.tag == "book" && Input.GetKey("e"))
{
itemweight = 1.2f;
ScoreManager.currentweight += itemweight;
other.gameObject.SetActive(false);
bookimage.color = visible;
isholding = true;
Color c = bookweightA.color;
c.a = 100;
bookweightA.color = c;
bookweightA.CrossFadeAlpha(0, 2, false);
/*timeleft -= Time.deltaTime;
Debug.Log(timeleft);
if (timeleft <= 0)
{
c.a = 0;
bookweightA.color = c;
timeleft = 0;
}*/
}
// If the entering collider is a map...
else if (other.gameObject.tag == "map" && Input.GetKey("e"))
{
itemweight = .2f;
ScoreManager.currentweight += itemweight;
other.gameObject.SetActive(false);
mapimage.color = visible;
isholding = true;
Color c = mapweightA.color;
c.a = 100;
mapweightA.color = c;
}
else
{
}
}
void DropItem()
{
if (bookimage.color == visible)
{
itemweight = 1.2f;
ScoreManager.currentweight -= itemweight;
bookimage.color = invisible;
Vector3 position = GameObject.Find("CollectableSpawnPoint").transform.position;
GameObject item = Instantiate(book, position, Quaternion.identity) as GameObject;
item.gameObject.tag = "book";
item.gameObject.SetActive(true);
}
if (mapimage.color == visible)
{
itemweight = .2f;
ScoreManager.currentweight -= itemweight;
mapimage.color = invisible;
Vector3 position = GameObject.Find("CollectableSpawnPoint").transform.position;
GameObject item = Instantiate(map, position, Quaternion.identity) as GameObject;
item.gameObject.tag = "map";
item.gameObject.SetActive(true);
}
isholding = false;
}
}**
```





