Quantcast
Channel: Questions in topic: "side-scrolling"
Viewing all articles
Browse latest Browse all 99

Platform color to kill player if player does not match

$
0
0
Hi, I am just starting out with Unity and C# and have actually been making pretty good progress, but a game mechanic I want to introduce is giving me problems. It is important as I wish to use it quite frequently throughout the game. As I said I'm just learning, but thought I'd take a whack at the code: using UnityEngine; using System; class PlatformColor : MonoBehaviour{ public bool isBlack; public bool isRed; public bool isBlue; private CharacterController2D _controller; private Player _player; public GiveDamageToPlayer _givedamagetoplayer; public bool IsDead { get; private set; } void Awake(){ _controller = GetComponent (); _player = GetComponent (); _givedamagetoplayer = GetComponent (); } void Update(){ if (isRed = true && Player.isRed == false) GiveDamageToPlayer; if (isBlack = true && Player.isBlack ==false) GiveDamageToPlayer; if (isBlue = true && Player.isBlue == false) GiveDamageToPlayer; } } I think I have the idea of it? Let me tell you what I THINK this script is doing. My idea is that by making the colors public bools, I can change them in the editor window in order to tell Unity which color the platform is because I don't know how else Unity would know. I am then calling my Controller, Player, and Damage scripts in the Start function. Where I just get lost is the next part. I feel like my update function maybe looks... kinda right? I want the platform to kill the player if his color doesn't match the platform color, but changing the player color will be another whole issue I'm sure. I feel like I should be using transform somewhere? Transform would = the platform is my understanding. Can someone please help me out or tell me if I am way way way off on what I am attempting.

Viewing all articles
Browse latest Browse all 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>