[RESOLVIDO] Ajuda com Script convertido
3 participantes
SchultzGames :: UNITY 3D :: Resolvidos
Página 1 de 1
[RESOLVIDO] Ajuda com Script convertido
Bom dia amigos
Eu converti esse script de js para c# naquele site tive que arrumar ele todo mais tem uma linha 45 aqui que nao estou conseguindo ajeitar
Eu converti esse script de js para c# naquele site tive que arrumar ele todo mais tem uma linha 45 aqui que nao estou conseguindo ajeitar
- Código:
using UnityEngine;
using System.Collections;
public class Boss : MonoBehaviour {
public GameObject targetPlayer;
public Transform transformOfPlayer;
public CharacterController charCon;
public Animation aiAnimation;
//Missle Spawn
public GameObject missle;
public GameObject mSpawn1;
public GameObject mSpawn2;
//Enemy Spawn
public GameObject LittleEnemy;
public GameObject EnemySpawn1;
public GameObject EnemySpawn2;
public int maxHealth;
public int currentHealth;
public int damageToPlayer;
public float clawRange;
public float shootingRange;
public float rotationSpeed;
public float maxIdleTime;
public float idleTimer;
public int aiStats;
public float playerDistance;
void Start (){
currentHealth = maxHealth;
targetPlayer = GameObject.FindGameObjectWithTag("Player");
transformOfPlayer = GameObject.FindGameObjectWithTag("Player").transform;
}
void Update (){
FIXME_VAR_TYPE myRotation= Quaternion.LookRotation(transformOfPlayer.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation,myRotation,Time.deltaTime*rotationSpeed);
transform.rotation.x = 0;
transform.rotation.z = 0;
idleTimer = idleTimer - Time.deltaTime;
playerDistance = Vector3.Distance(transform.position, transformOfPlayer.transform.position);
if(playerDistance <= clawRange)
{
aiStats = 0;
}
if(shootingRange >= playerDistance && playerDistance > clawRange)
{
aiStats = 1;
}
if(playerDistance > shootingRange)
{
aiStats = 2;
}
if(aiStats == 0 && idleTimer < 0)
{
aiAnimation.Play("bossAiClaw");
idleTimerReset();
}
if(aiStats == 1 && idleTimer < 0)
{
aiAnimation.Play("bossAiShooting");
idleTimerReset();
}
if(aiStats == 2 && idleTimer < 0)
{
aiAnimation.Play("bossAiSwarming");
idleTimerReset();
}
}
void idleTimerReset (){
idleTimer = Random.Range(0,maxIdleTime);
}
void PlayerToEnemyDamage ( int theDamage ){
currentHealth -= theDamage;
if(currentHealth <= 0)
{
currentHealth = 0;
aiStats = 4;
}
}
void EnemyAttack (){
if(playerDistance<clawRange)
{
targetPlayer.transform.SendMessage("EnemyToPlayerDamage",damageToPlayer,SendMessageOptions.DontRequireReceiver);
}
}
void missleAtk (){
GameObject myMissle;
myMissle = Instantiate(missle,mSpawn1.transform.position,mSpawn1.transform.rotation);
GameObject myMissle2;
myMissle2 = Instantiate(missle,mSpawn2.transform.position,mSpawn2.transform.rotation);
}
void EnemySpawn (){
GameObject MyEnemySpawn1;
MyEnemySpawn1 = Instantiate(LittleEnemy,EnemySpawn1.transform.position,mSpawn1.transform.rotation);
GameObject MyEnemySpawn2;
MyEnemySpawn2 = Instantiate(LittleEnemy,EnemySpawn2.transform.position,mSpawn2.transform.rotation);
}
}
Última edição por dstaroski em Sex Abr 07, 2017 7:37 am, editado 2 vez(es) (Motivo da edição : Resolvido)
Re: [RESOLVIDO] Ajuda com Script convertido
Bom dia cara! Já tenta-se apagar o "FIXME_VAR_TYPE"? faça um teste,
Abraço!
Abraço!
Re: [RESOLVIDO] Ajuda com Script convertido
Sim amigo apaguei mais esta dando erro o script em js e esse talvez ajude olhando ele
- Código:
var targetPlayer : GameObject;
var transformOfPlayer : Transform;
var charCon : CharacterController;
var aiAnimation : Animation;
//Missle Spawn
var missle : GameObject;
var mSpawn1 : GameObject;
var mSpawn2 : GameObject;
//Enemy Spawn
var LittleEnemy : GameObject;
var EnemySpawn1 : GameObject;
var EnemySpawn2 : GameObject;
var maxHealth : int;
var currentHealth : int;
var damageToPlayer : int;
var clawRange : float;
var shootingRange : float;
var rotationSpeed : float;
var maxIdleTime : float;
var idleTimer : float;
var aiStats : int;
var playerDistance : float;
function Start ()
{
currentHealth = maxHealth;
targetPlayer = GameObject.FindGameObjectWithTag("Player");
transformOfPlayer = GameObject.FindGameObjectWithTag("Player").transform;
}
function Update ()
{
var myRotation = Quaternion.LookRotation(transformOfPlayer.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation,myRotation,Time.deltaTime*rotationSpeed);
transform.rotation.x = 0;
transform.rotation.z = 0;
idleTimer = idleTimer - Time.deltaTime;
playerDistance = Vector3.Distance(transform.position, transformOfPlayer.transform.position);
if(playerDistance <= clawRange)
{
aiStats = 0;
}
if(shootingRange >= playerDistance && playerDistance > clawRange)
{
aiStats = 1;
}
if(playerDistance > shootingRange)
{
aiStats = 2;
}
if(aiStats == 0 && idleTimer < 0)
{
aiAnimation.Play("bossAiClaw");
idleTimerReset();
}
if(aiStats == 1 && idleTimer < 0)
{
aiAnimation.Play("bossAiShooting");
idleTimerReset();
}
if(aiStats == 2 && idleTimer < 0)
{
aiAnimation.Play("bossAiSwarming");
idleTimerReset();
}
}
function idleTimerReset()
{
idleTimer = Random.Range(0,maxIdleTime);
}
function PlayerToEnemyDamage(theDamage : int)
{
currentHealth -= theDamage;
if(currentHealth <= 0)
{
currentHealth = 0;
aiStats = 4;
}
}
function EnemyAttack()
{
if(playerDistance<clawRange)
{
targetPlayer.transform.SendMessage("EnemyToPlayerDamage",damageToPlayer,SendMessageOptions.DontRequireReceiver);
}
}
function missleAtk()
{
var myMissle : GameObject;
myMissle = Instantiate(missle,mSpawn1.transform.position,mSpawn1.transform.rotation);
var myMissle2 : GameObject;
myMissle2 = Instantiate(missle,mSpawn2.transform.position,mSpawn2.transform.rotation);
}
function EnemySpawn()
{
var MyEnemySpawn1 : GameObject;
MyEnemySpawn1 = Instantiate(LittleEnemy,EnemySpawn1.transform.position,mSpawn1.transform.rotation);
var MyEnemySpawn2 : GameObject;
MyEnemySpawn2 = Instantiate(LittleEnemy,EnemySpawn2.transform.position,mSpawn2.transform.rotation);
}
Re: [RESOLVIDO] Ajuda com Script convertido
Faz assim, tenta declarar uma variavel com esse myrotation sendo um transform, e no update deixa ele ele como está, com o myrotation = e bla bla bla, essas conversões online não são muito boas não cara, se não der, vamos aguardar que daqui a pouco aparece alguém que entende mais e talvez consiga resolver pra ti.
Abraço!
Abraço!
Re: [RESOLVIDO] Ajuda com Script convertido
Bom dia! pois é cara, dai nessa parte de conversão não sei mais como te ajudar, pelo que vi você está programando uma IA para chefe certo? você não encontrou nada em C#? ou melhor, já tentou programar do zero uma IA para o Boss?Callyde Jr escreveu:Bom dia amigo
Nao funcionou apareceu um monte de erros
Abraço!
Re: [RESOLVIDO] Ajuda com Script convertido
Boa tarde brother exatamente IA para chefe
bom estou tentando criar um aqui usando partes desse scripts
bom estou tentando criar um aqui usando partes desse scripts
Re: [RESOLVIDO] Ajuda com Script convertido
Ué, tente usar uma variável do tipo Quaternin... você está jogando uma rotação nela, logo, via servir.
Re: [RESOLVIDO] Ajuda com Script convertido
Bom dia amigos
Hummm e verdade não pensei nisso obrigado Marcos coloquai assim mais apareceram esses erros logo abaixo?
[list=linenums]
[*]
[/list]
[list=linenums]
[*]
[/list]
Hummm e verdade não pensei nisso obrigado Marcos coloquai assim mais apareceram esses erros logo abaixo?
- Código:
void Update (){
Quaternio = myRotation = Quaternion.LookRotation(transformOfPlayer.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation,myRotation,Time.deltaTime*rotationSpeed);
transform.rotation.x = 0;
transform.rotation.z = 0;
- Código:
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(46,16): error CS0029: Cannot implicitly convert type `UnityEngine.Quaternion' to `float
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(47,35): error CS1502: The best overloaded method match for `UnityEngine.Quaternion.Slerp(UnityEngine.Quaternion, UnityEngine.Quaternion, float)' has some invalid arguments
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(47,35): error CS1503: Argument `#2' cannot convert `float' expression to type `UnityEngine.Quaternion'
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(48,13): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.rotation'. Consider storing the value in a temporary variable
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(49,13): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.rotation'. Consider storing the value in a temporary variable
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(115,3): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(118,3): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(124,3): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
Assets/Arquivos/Scripts/Boss/Scripts/Boss.cs(127,3): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
[list=linenums]
[*]
[/list]
[list=linenums]
[*]
[/list]
Re: [RESOLVIDO] Ajuda com Script convertido
- Código:
using UnityEngine;
using System.Collections;
public class Boss : MonoBehaviour {
public GameObject targetPlayer;
public Transform transformOfPlayer;
public CharacterController charCon;
public Animation aiAnimation;
//Missle Spawn
public GameObject missle;
public GameObject mSpawn1;
public GameObject mSpawn2;
//Enemy Spawn
public GameObject LittleEnemy;
public GameObject EnemySpawn1;
public GameObject EnemySpawn2;
public int maxHealth;
public int currentHealth;
public int damageToPlayer;
public float clawRange;
public float shootingRange;
public float rotationSpeed;
public float maxIdleTime;
public float idleTimer;
public int aiStats;
public float playerDistance;
void Start (){
currentHealth = maxHealth;
targetPlayer = GameObject.FindGameObjectWithTag("Player");
transformOfPlayer = GameObject.FindGameObjectWithTag("Player").transform;
}
void Update (){
Quaternion myRotation = Quaternion.LookRotation(transformOfPlayer.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation,myRotation,Time.deltaTime*rotationSpeed);
transform.eulerAngles = new Vector3 (0, transform.eulerAngles.z, 0);
idleTimer = idleTimer - Time.deltaTime;
playerDistance = Vector3.Distance(transform.position, transformOfPlayer.transform.position);
if(playerDistance <= clawRange)
{
aiStats = 0;
}
if(shootingRange >= playerDistance && playerDistance > clawRange)
{
aiStats = 1;
}
if(playerDistance > shootingRange)
{
aiStats = 2;
}
if(aiStats == 0 && idleTimer < 0)
{
aiAnimation.Play("bossAiClaw");
idleTimerReset();
}
if(aiStats == 1 && idleTimer < 0)
{
aiAnimation.Play("bossAiShooting");
idleTimerReset();
}
if(aiStats == 2 && idleTimer < 0)
{
aiAnimation.Play("bossAiSwarming");
idleTimerReset();
}
}
void idleTimerReset (){
idleTimer = Random.Range(0,maxIdleTime);
}
void PlayerToEnemyDamage ( int theDamage ){
currentHealth -= theDamage;
if(currentHealth <= 0)
{
currentHealth = 0;
aiStats = 4;
}
}
void EnemyAttack (){
if(playerDistance<clawRange)
{
targetPlayer.transform.SendMessage("EnemyToPlayerDamage",damageToPlayer,SendMessageOptions.DontRequireReceiver);
}
}
void missleAtk (){
Instantiate(missle,mSpawn1.transform.position,mSpawn1.transform.rotation);
Instantiate(missle,mSpawn2.transform.position,mSpawn2.transform.rotation);
}
void EnemySpawn (){
Instantiate(LittleEnemy,EnemySpawn1.transform.position,mSpawn1.transform.rotation);
Instantiate(LittleEnemy,EnemySpawn2.transform.position,mSpawn2.transform.rotation);
}
}
Tópicos semelhantes
» [RESOLVIDO] ajuda no script
» [RESOLVIDO] AJUDA COM SCRIPT
» [RESOLVIDO] Ajuda com Script de Mensagem
» [RESOLVIDO] Ajuda com script simples
» [RESOLVIDO] Ajuda com uma script (JavaScript)
» [RESOLVIDO] AJUDA COM SCRIPT
» [RESOLVIDO] Ajuda com Script de Mensagem
» [RESOLVIDO] Ajuda com script simples
» [RESOLVIDO] Ajuda com uma script (JavaScript)
SchultzGames :: UNITY 3D :: Resolvidos
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos