zbrush и несколько уроков внимательно смотреть. My WebPage начни с этого
Добавлено (30 Мая 2018, 22:28)
---------------------------------------------
а вот мне никто не помог
Код
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EnemyData : MonoBehaviour
{
public float Speed;
public float LiveTime;
public static int LiveShipTranslation;
public int DamageEnemy,HpShip=100;
private int Live=1;
public float DistTach;
public int Score;
public GameObject Ship;
public GameObject Enemy;
void Start ()
{
Destroy(gameObject,LiveTime);
Ship=GameObject.Find("Ship01");
HpShip=HPShip.LiveShip;
LiveShipTranslation=HpShip;
//for(int i=5; i>0; i--){Debug.Log("EnemyData.step__"+i);}
Debug.Log("EnemyData.HpShip_"+HpShip);
Debug.Log("EnemyData.LiveShipTranslation__"+LiveShipTranslation);
}
void Update ()
{
transform.Translate(Vector3.forward*Time.deltaTime*Speed);
Debug.Log("HpShip_"+HpShip);
Debug.Log("LiveShipTranslation__"+LiveShipTranslation);
if(Ship)
{
if(Vector3.Distance(Ship.transform.position,transform.position)<DistTach)
{
HpShip-=DamageEnemy;
//Debug.Log("+EnemyData+HpShip+"+HpShip);
LiveShipTranslation=HpShip;
Destroy(Enemy);
}
}
if(Live<1)
{
Destroy(Enemy);
}
}
}
Код
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HPShip : MonoBehaviour
{
public static int LiveShip;
public int LiveShipe;
public GameObject Ship;
public Slider Slider;
void Start ()
{
LiveShip=10;
Ship=GameObject.Find("Ship01");
LiveShip=LiveShipe;
Debug.Log("HPShip.LiveShipe_"+LiveShipe);
Debug.Log("HPShip.LiveShip_"+LiveShip);
}
void Update ()
{
//LiveShip=EnemyData.LiveShipTranslation;
//Debug.Log("=*LiveHp*="+LiveShip);
if(LiveShip<1)
{
Destroy(Ship);
Application.LoadLevel("GameOver");
}
Slider.value=LiveShip;
}
}
вот что выдает
EnemyData.HpShip_0
UnityEngine.Debug:Log(Object)
EnemyData:Start() (at Assets/Scripts/EnemyData.cs:25)
EnemyData.LiveShipTranslation__0
UnityEngine.Debug:Log(Object)
EnemyData:Start() (at Assets/Scripts/EnemyData.cs:26)
HPShip.LiveShipe_100
UnityEngine.Debug:Log(Object)
HPShip:Start() (at Assets/Scripts/HPShip.cs:18)
HPShip.LiveShip_100
UnityEngine.Debug:Log(Object)
HPShip:Start() (at Assets/Scripts/HPShip.cs:19)
HpShip_0
UnityEngine.Debug:Log(Object)
EnemyData:Update() (at Assets/Scripts/EnemyData.cs:33)
LiveShipTranslation__0
UnityEngine.Debug:Log(Object)
EnemyData:Update() (at Assets/Scripts/EnemyData.cs:34)
не пойму почему принимает нули...
ну почему LiveShipTranslation__0 принимает ноль понятно а почему EnemyData.HpShip_0 принимает 0 разобраться не могу. я даже притормаживал скрипт эними. там строка исключена пофиг, все равно к нулю приходит.Добавлено (30 Мая 2018, 23:03)
---------------------------------------------
я уж как только не кручусь, мне установку жизний надо сделать в юнити, передать это другому скрипту обработать и вернуть первому, так как на этом скрипте будет висеть разные объекты с разными параметрами. вот еще эксперементы. можно конечно сразу присвоить значение в скрипте...
Код
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HPShip : MonoBehaviour
{
public int LiveShipe;
public static int LiveShip=100;
public GameObject Ship;
public Slider Slider;
void Start ()
{
LiveShip=10;
Ship=GameObject.Find("Ship01");
LiveShip=LiveShipe;
//Debug.Log("HPShip.LiveShipe_"+LiveShipe);
Debug.Log("HPShip.LiveShip_"+LiveShip);
}
void Update ()
{
//LiveShip=EnemyData.LiveShipTranslation;
//Debug.Log("=*LiveHp*="+LiveShip);
if(LiveShip<1)
{
Destroy(Ship);
Application.LoadLevel("GameOver");
}
Slider.value=LiveShip;
}
}
Код
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EnemyData : MonoBehaviour
{
public float Speed;
public float LiveTime;
public static int LiveShipTranslation;
public int DamageEnemy,HpShip=100;
private int Live=1;
public float DistTach;
public int Score;
public GameObject Ship;
public GameObject Enemy;
void Start ()
{
for(int i=5; i>0; i--){Debug.Log("EnemyData.step__"+i);}
Destroy(gameObject,LiveTime);
Ship=GameObject.Find("Ship01");
HpShip=HPShip.LiveShip;
LiveShipTranslation=HpShip;
Debug.Log("EnemyData.HpShip_"+HpShip);
//Debug.Log("EnemyData.LiveShipTranslation__"+LiveShipTranslation);
}
void Update ()
{
transform.Translate(Vector3.forward*Time.deltaTime*Speed);
Debug.Log("HpShip_"+HpShip);
Debug.Log("LiveShipTranslation__"+LiveShipTranslation);
if(Ship)
{
if(Vector3.Distance(Ship.transform.position,transform.position)<DistTach)
{
HpShip-=DamageEnemy;
//Debug.Log("+EnemyData+HpShip+"+HpShip);
LiveShipTranslation=HpShip;
Destroy(Enemy);
}
}
if(Live<1)
{
Destroy(Enemy);
}
}
}
вот данные консоли
Код
EnemyData.step__5
UnityEngine.Debug:Log(Object)
EnemyData:Start() (at Assets/Scripts/EnemyData.cs:20)
EnemyData.step__4
UnityEngine.Debug:Log(Object)
EnemyData:Start() (at Assets/Scripts/EnemyData.cs:20)
EnemyData.step__3
UnityEngine.Debug:Log(Object)
EnemyData:Start() (at Assets/Scripts/EnemyData.cs:20)
EnemyData.step__2
UnityEngine.Debug:Log(Object)
EnemyData:Start() (at Assets/Scripts/EnemyData.cs:20)
EnemyData.step__1
UnityEngine.Debug:Log(Object)
EnemyData:Start() (at Assets/Scripts/EnemyData.cs:20)
EnemyData.HpShip_100
UnityEngine.Debug:Log(Object)
EnemyData:Start() (at Assets/Scripts/EnemyData.cs:25)
HPShip.LiveShip_100
UnityEngine.Debug:Log(Object)
HPShip:Start() (at Assets/Scripts/HPShip.cs:20)
HpShip_100
UnityEngine.Debug:Log(Object)
EnemyData:Update() (at Assets/Scripts/EnemyData.cs:33)
LiveShipTranslation__100
UnityEngine.Debug:Log(Object)
EnemyData:Update() (at Assets/Scripts/EnemyData.cs:34)
да, я добился своего только не тем способом!((