Created
April 8, 2019 23:41
-
-
Save DB-009/54e3ffaa43403c94a6acedbcd75f1096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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