Question by
MrCrumbl3d · May 03, 2017 at 07:02 AM ·
collisionoverlappingcolliding
Colliding with other objects. How to stop it?
Hello... im stuck with this problem. My problem is when i pick up some object and place it and pick up some another objects after that when i collide with another object my button change to pickup and when i click it the other obect stick to another object that the player holding... if you dont understand.. you can check my video (https://www.youtube.com/watch?v=atTg-IgfClw&t=15s) please help me :(n
My scipt:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class wallsPickup : MonoBehaviour {
public GameObject onHand;
public GameObject unParent;
public bool isCarrying;
public bool isPickUp;
public GUISkin skin = null;
public Texture2D btnPlace = null;
public Texture2D btnPickUp = null;
void Start () {
isCarrying = false;
isPickUp = false;
}
void OnCollisionStay (Collision col) {
if(col.gameObject.tag == "Player")
{
isPickUp = true;
}
}
void OnCollisionExit () {
isPickUp = false;
isCarrying = false;
}
void OnGUI() {
GUI.skin = skin;
if (isCarrying == true) {
if (GUI.Button (new Rect (Screen.width - 200,Screen.height - 200,160,160), btnPlace)) {
this.transform.parent = unParent.transform;
isPickUp = false;
print("clicked");
}
}
if (isPickUp == true) {
if (GUI.Button (new Rect (Screen.width - 200,Screen.height - 200,160,160), btnPickUp)) {
this.transform.parent = onHand.transform;
isCarrying = true;
isPickUp = false;
}
}
}
}
Comment