Quantcast
Channel: Latest Questions by esitoinatteso
Viewing all articles
Browse latest Browse all 92

Can't Understand GetComponent C#

$
0
0
Hi there. I realize it's my fault here, because I'm just too dummy to understand how it works from the tons of examples everybody can easily find here or in other sites. How do I use GetComponent? I've been in the docs, I've visited a lot of questions, I've seen a lot of examples but still I'm getting errors when it comes to write one on my own. Here is what I've understood of how GetComponent works: You got 2 scripts, script A and script B, there's no need of a parent/child relation. You declare a new public variable in script A, go to script B and then you write...? For example: I want to make a script to handle all common variables of my enemies. That way I won't have to write those variables for each one of them, it makes sense? Variables like enemySpeed, enemyDamage, and so on. Done that, I create a new c#script and call it with the specific name of an enemy, like Thug, I make it a child of my Enemy script by typing Public Class Thug : Enemy{} and I now want to access and modify all the values I've already written in Enemy. How do I do that? Is this reasonable? Sorry this is a very basic question but I'm unable to get past it... and because of this, could you please be exhaustive in your answers? like, really verbose and full of examples? Keep in mind that all the existing examples weren't enough to make me understand... I may have clenched that this process is easier in JavaScript though. Thanks a lot for the patience.

Viewing all articles
Browse latest Browse all 92

Trending Articles



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