Question by
pachoramirez86 · Nov 06, 2019 at 02:38 PM ·
collisionscript.
Colliders not working right
Hello everyone, im working on a simple game dragging and dropping gameObjects, basically what you have to do is that u have a background where you pick trash up and you have to drop into a specific trash can, and when the trashcan is right the trash gets deleted.
The models im using were all imported from blender if that changes something and every object has colliders and a rigid body
The class im using to drag is working just fine but for some reason the colliders between the trash can and the trash just don't work, im using this code to do the collision
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
public class botarbasura : MonoBehaviour
{
void OnCollisionEnter(Collision other)
{
if (other.gameObject.name == "escombros")
{
Destroy(other.gameObject);
}
}
}
Im also including the code from the drag script
using UnityEngine;
using UnityEngine.EventSystems;
public class arrastrar : MonoBehaviour, IDragHandler
{
public float z = 0.0f;
public void OnDrag(PointerEventData eventData)
{
Vector3 mousePosition = Input.mousePosition;
mousePosition.z = z;
transform.position = Camera.main.ScreenToWorldPoint(mousePosition);
}
}
Comment
Your answer