Skip to content

Instantly share code, notes, and snippets.

@DB-009
Created April 8, 2019 23:41
Show Gist options
  • Save DB-009/54e3ffaa43403c94a6acedbcd75f1096 to your computer and use it in GitHub Desktop.
Save DB-009/54e3ffaa43403c94a6acedbcd75f1096 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class tileControl : MonoBehaviour
{
// Start is called before the first frame update
public string tileType;//if its lava if its grass etc
private void OnCollisionEnter(Collision objectHit)
{
if (objectHit.gameObject.tag == "Player")//if player walks on tile do follwoing
{
if (tileType == "lava")//if lava push player up and later do damage or kill player
{
GameObject player = GameObject.FindGameObjectWithTag("Player");//find the player object
player.GetComponent<Rigidbody>().AddForce(0, 10, 0, ForceMode.Impulse);//add force to make him fly up
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment