Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Android platform simple script that works on PC - not a member of 'UnityEngine'

$
0
0
Hey there, I'm so happy that android build is now available for free! So I tried to build my project but I ran into few compile errors, most of them were declaration fails, which were easy to fix... but there is a fail, compile error that I don't know how to fix or work around function Update () { if (Input.GetMouseButtonDown(0)) { //ray shooting out of the camera from where the mouse is var hit : RaycastHit; var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, hit)) { // if object isn't enemy, return from whole function if (hit.collider.gameObject.tag != "Enemy") { return; } // ENEMY INPUT: var enemy_script_name = hit.collider.gameObject.name; var enemy = hit.collider.gameObject.GetComponent(enemy_script_name); // Connect Enemy instance, enemy script name == enemy name! var enemy_attack_dmg : float = enemy.enemy_attack_damage; // Set enemy damage //... more stuff in the script, } } } But then I get this compile error: > Assets/jan_hexadventure/scripts/player_script/player_fight.js(65,54):> BCE0019: 'enemy_attack_damage' is not a member of 'UnityEngine.Component'.> It works fine on PC build, it does that with other objects too, so I'm wondering, is there a way to properly fix this (without rewriting the whole function) ? Thx for reading :)

Viewing all articles
Browse latest Browse all 171066

Trending Articles