i need to set a gameobject as a trigger and colision.

i need gameobject to be a trigger but also act as a collider and bounce off the other object

but my code has a collision enter 2d on it and I must set it as a trigger

and when you set it as trigger it doesn’t collide anymore but goes straight thru items with no bounce

so how do I get both on the object trigger and collider with reflect bounce off each other etc?

using UnityEngine;
using System.Collections;

public class cut2 : MonoBehaviour {

				public Animator anim;
		private int collisionCount = 1;
				

				// Use this for initialization
				void Start () {
						anim = GetComponent<Animator> ();
				}

				// Update is called once per frame
				//void Update()
				//{
		void OnTriggerEnter2D(Collider2D other)
		/*
						if (coll.gameObject.tag == "Enemy")
								//if (Input.GetKeyDown("1"))
						{					anim.Play ("22", -1, 0f);
						}
*/
					

						{
								if(collisionCount == 1)
								{
						//anim.Play ("333", -1, 0f);


										anim.Play ("22", -1, 0f);
										 //Play first animation
								}
								else if(collisionCount == 2)
								{
										anim.Play ("333", -1, 0f);
										//Play second animation
										 }
								else if(collisionCount == 3)
								{
										//Play third animation
								}
								 }


		void OnTriggerExit2D(Collider2D other) {

						{
								if(collisionCount == 3)
										{
										collisionCount = 1;
								}
								else
								{
									 collisionCount += 1;
								}
						}
					

						}


				}

@sid4 Try adding more than one collider. Have one collider that is trigger, and one collider to collide with objects.

An even better option is to use the OnCollisionEnter2D function. From this script, I can’t quite tell what you are trying to do, but I think this function will work well for you. OnCollisionEnter2D works the same way as OnTriggerEnter2D, except instead of triggering when something enters the collider, it triggers when something touches the collider. Again, I don’t know if this will work with what you are doing, but it is worth a try. BTW your script formatting could use a lot of work :wink:

I had a similar situation and resorted to having 3 triggerzones. at first just one is active and that triggers the first animation, but that ALSO enables the second triggerzone. sounds messy but
1st zone OnTriggerEnter plays animation 1 and enables the collider on triggerzone 2, on triggerexit 1

2nd zone OnTriggerENter plays animation 2 and enables the collider on triggerzone 3

need to disable the trigger or the script on each zone after it has been used, or destroy the trigger all together if you are done with it

ontriggerenter to play animation

or actually OnTriggerExit may be better to enable the next trigger zone
ontriggerstay or ontriggerexit to enable the next triggerzone and destroy or disable the previous triggerzone. here is a sample of what I would have on the first triggerzone

using UnityEngine;
using System.Collections;

public class triggerOneScript : MonoBehaviour {
	 BoxCollider zone2;
	BoxCollider zone1;
	 Animation animation;

	void Start () {
		zone1 = GetComponent<BoxCollider>();
		zone2 = GameObject.Find("trigger2").GetComponent<BoxCollider>();
		animation = GameObject.Find("tLayer").GetComponent<Animation>();
	}

	
	void OnTriggerEnter(Collider other) {
		if(other.tag == "Player")
		{
			animation.Play();
		}
		}
		void OnTriggerExit(Collider other) {
			if(other.tag == "Player")
			{
				zone2.enabled = true;
			zone1.enabled = false;
			}
	
}
}