SchultzGames
Para tirar dúvidas, crie um tópico especifico na área "Dúvidas em Geral" e aguarde ser respondido. Evite comentar em tópicos não relacionados a sua dúvida :D
TÓPICOS RECENTES:
Tópico:
Postado em:
Postado por:
Procuro freelancer
Novo Teaser do jogo Dark Age
Unity Admob Erro
Mais Um jogo!
DEATH ISLAND 0.2.5 SURVIVAL GAME 4 ANOS EM DESENVOLVIMENTO
Player travando na colisão com o chão Unity 2D
Sombras estão quadradas na build
nao consigo fazer o player sentar no sofa alguem me ajuda
Unity - Ao mudar de scene, todas as Lights são deletadas
210 Linhas de código para inimigo é muito grande?
modelar avatar e skins para um jogo web
Collider (mesh?)
ShapeKeys do Blender para a Unity altera áreas próximas
COMO EVITAR QUE UM OBJETO (PLAYER,ITEM ETC...) ATRAVESSE UMA PAREDE.
Ajuda em Script de Verificação de Ação e Reação
unity Failed to load PlayerSettings (internal index #0). Most likely data f
PRECISO FAZER QUE MEU GAME FIQUE ONLINE
Materiais do Blander não aparecem no MeshRendere do Objeto na Unity
Repetiçoes de Textura no Terreno
SERVER IS DOWN - UNITY+MSQL
Procuro programadores - Novo jogo
Problema com o MS VEHICLES
Preciso de ajuda com a Unity
Problema com vídeo em 360° na Unity
Problemas no MS Vehicles
unity- eventos na Animação com Armature/Bones vinda do blender não funciona
ajuda exibir resultados simulados em uma liga Game Unity
Unity - ParticleSystem não é redirecionado no rawimage no canvas
Como resolver o problema de "face orientation" no Blender.
[DÚVIDA] Tive um problema com meu Canvas
erro na Directional Light
Problemas com o Directional Light da Unity 3D
Novo jogo da franquia Sphere game em desenvolvimento
malha da roda não girando com wheel collider unity
Problemas com ambiguidade
Touch mobile
INVALID TOKEN
Como acessar o "HD Render Pipeline" do HDRP por script?
CHAT GPT PRA JOGO DE TIRO? comentem
Tutorial script inimigo segue e foge do player
Ainda vale a pena lançar Asset na Asset Store?
Ajuda com tabela de historico de pontuaçao.
[TUTORIAL] Entrar no carro estilo GTA
Como derrapar um Whell Collider
Como altertar o valor do "Asymptote Value" do Whell Collider via Script
Preciso de ajuda para substituir valor de variavel em outro script
Ajuda com Top Down Shooter utilizando Photon
Duvida com Netcode
[RESOLVIDO] Unity - Movendo a Câmera na Horizontal/Vertical com Touch
Alguém me ajuda com os anúncios pfv
Segundo Trailer do jogo Dark Age, Feliz Natal a todos!
Unity - ScrollRect, Viewport, Content - O Conteúdo ñ inicia no topo
Coleta de itens
Unity - Cadastro do email do jogador
[GRATIS] PACK DE MODELOS 3D PARA JOGO DE TERROR
Onde Conseguir músicas para meu Jogo?
error CS0246 em Script
Alguem teve ja esse problema?
[Projeto em Andamento] Draug, um jogo de hordas
DISPONIVEL PARA FAZER MODELOS 3D
Unity-Loja.Como os Jogadores terão acesso aos ítens comprados na PlayStore?
Bugando depois do Build.
Primeiro Trailer do jogo Dark Age
Problema com sombra
Mesh e Material do objeto trocando para uma instancia no inicio do jogo
[RESOLVIDO] Unity - RawImages_Layer_Camera
INVESTIMENTO EM JOGOS E BANCO DE TALENTO
Teaser do meu novo projeto pessoal, Dark Age
Preciso de ajuda com mudança para mobile androide.
[RESOLVIDO] Posição final do objeto em jogo 2D
Input.GetAxis() obedercer a orientação de um objeto.
Interação com elementos UI
Meu primeiro jogo na steam
Minimap/Radar/GPS Estilo GTA V
[RESOLVIDO] Erro no console depois que formatei o pc
PACK GRÁTIS de Músicas ELETRÔNICAS para ajudar vocês em seus Jogos Indies!
[TUTORIAL] Entenda como funciona: ENUM, SWITCH, BREAK, CASE no C#
O Labirinto II - Baixe o Jogo
Qual e o codigo de Botões na unity para saber seus estados?
Como carregar itens pequenos dentro do carro sem que atravesse os colliders
[Duvida] Script pegar itens
Travamento ao trocar de cena
Colisão zoada e movimentação
Salvar objetos que foram destruidos entre cenas na unity
Quero começa a desenvolver um jogo de luta porem eu queria aprender a faze
Pegar qual objeto colidiu com o Linecast.
movimentação e camera?
[RESOLVIDO] Unity - SceneManager.LoadScene abre scene com objeto "vazio"
[RESOLVIDO] ajuda sobre skybox
MEU SIMULADOR DE CARRO
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY
[RESOLVIDO] Ausencia da funçao NavMesh na Unity 2022.2.12
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY - 2
Roll Up Um jogo de aventura e desáfios
Terminologia da Unity em outras engines
Como criar a iluminação do Sol no Sistema Solar?
Conexão de lobby pelo OnConnectedToMaster
Problema na exportção de projeto unity
[RESOLVIDO] Unity - Áudios estão emitindo som só Depois do Botão ser solto
Ontem à(s) 3:34 pm
Seg Abr 22, 2024 5:15 pm
Seg Abr 15, 2024 12:23 pm
Sáb Abr 13, 2024 11:37 am
Qua Abr 10, 2024 1:33 am
Ter Abr 09, 2024 10:28 am
Seg Abr 08, 2024 9:27 pm
Seg Abr 08, 2024 8:01 am
Sáb Abr 06, 2024 8:05 pm
Qui Abr 04, 2024 11:34 pm
Qui Abr 04, 2024 11:13 pm
Qui Abr 04, 2024 11:10 pm
Sex Mar 22, 2024 2:41 pm
Dom Mar 10, 2024 2:30 pm
Sex Mar 01, 2024 1:27 pm
Qui Fev 22, 2024 9:57 pm
Ter Fev 20, 2024 9:28 am
Ter Fev 20, 2024 12:15 am
Seg Fev 19, 2024 1:06 pm
Seg Fev 12, 2024 1:56 pm
Seg Fev 12, 2024 1:17 pm
Dom Fev 11, 2024 8:55 pm
Dom Fev 11, 2024 11:16 am
Seg Fev 05, 2024 4:18 pm
Dom Fev 04, 2024 9:39 pm
Qua Jan 31, 2024 11:59 pm
Ter Jan 30, 2024 7:37 pm
Ter Jan 23, 2024 6:33 pm
Dom Jan 21, 2024 6:03 pm
Sáb Jan 20, 2024 7:03 pm
Sáb Jan 20, 2024 6:58 pm
Sáb Jan 20, 2024 6:39 pm
Sex Jan 19, 2024 8:40 am
Dom Jan 14, 2024 5:30 pm
Qua Jan 10, 2024 10:29 pm
Qua Jan 10, 2024 8:55 pm
Qua Jan 10, 2024 7:14 pm
Ter Jan 09, 2024 3:55 pm
Ter Jan 09, 2024 8:04 am
Sáb Jan 06, 2024 8:02 pm
Sex Jan 05, 2024 7:01 am
Sex Jan 05, 2024 12:12 am
Qui Jan 04, 2024 6:55 pm
Qui Jan 04, 2024 12:52 pm
Qui Jan 04, 2024 4:34 am
Ter Jan 02, 2024 11:48 pm
Dom Dez 31, 2023 7:25 pm
Qua Dez 27, 2023 5:44 pm
Qua Dez 27, 2023 3:08 pm
Sáb Dez 23, 2023 7:27 pm
Sáb Dez 23, 2023 5:06 pm
Qui Dez 21, 2023 8:10 pm
Seg Dez 18, 2023 2:04 pm
Sex Dez 15, 2023 5:11 pm
Qui Dez 14, 2023 9:13 pm
Qui Dez 14, 2023 2:47 pm
Qui Dez 14, 2023 1:48 pm
Qua Dez 13, 2023 8:58 pm
Ter Dez 12, 2023 2:32 pm
Seg Dez 11, 2023 1:53 pm
Qua Dez 06, 2023 8:13 pm
Sáb Dez 02, 2023 8:06 pm
Qui Nov 30, 2023 7:49 am
Seg Nov 27, 2023 1:35 am
Qua Nov 22, 2023 7:37 am
Qui Nov 09, 2023 1:22 pm
Seg Nov 06, 2023 11:59 am
Ter Out 31, 2023 9:53 am
Dom Out 29, 2023 8:05 pm
Dom Out 29, 2023 3:03 am
Sex Out 27, 2023 3:43 pm
Sex Out 27, 2023 3:28 pm
Qua Out 25, 2023 1:20 pm
Seg Out 23, 2023 10:34 am
Dom Out 22, 2023 6:55 pm
Qui Out 19, 2023 11:57 pm
Qui Out 19, 2023 6:39 pm
Ter Out 17, 2023 6:37 pm
Ter Out 17, 2023 6:18 pm
Seg Out 16, 2023 1:59 pm
Sáb Out 14, 2023 12:15 pm
Qua Out 11, 2023 6:07 pm
Seg Out 09, 2023 4:19 pm
Qua Out 04, 2023 12:12 pm
Qua Out 04, 2023 12:11 pm
Ter Out 03, 2023 9:18 pm
Ter Out 03, 2023 9:08 pm
Ter Out 03, 2023 6:05 pm
Ter Set 26, 2023 12:45 pm
Seg Set 25, 2023 9:02 pm
Seg Set 25, 2023 9:47 am
Sáb Set 23, 2023 2:10 pm
Sex Set 22, 2023 9:01 pm
Qui Set 21, 2023 11:04 am
Qua Set 20, 2023 4:40 pm
Qua Set 20, 2023 9:15 am
Dom Set 17, 2023 12:17 pm
Sex Set 15, 2023 7:24 pm
Sex Set 15, 2023 5:41 pm



































































































Joystick - Android

2 participantes

Ir para baixo

DÚVIDA Joystick - Android

Mensagem por VSouza Seg Jul 11, 2016 1:14 pm

Olá, baixei um asset free na asset store de um player2d que já vem com os movimentos configurados para o pc/joystick, queria criar um joystick virtual que simulasse as teclas do teclado. Dei uma olhada nos tutoriais disponíveis e não consegui achar nada para um jogo 2D. 

O player depende apenas de 6  teclas para funcionamento, eis a minha duvida: exite algum jeito de fazer com que um botão UI realize a mesma função da letra A? Digo não que ao clicar no botão ele entenda que é pra executar um daqueles Axis do Input, mas sim fazendo com que o jogo acredite que a tecla que foi apertada foi a do teclado. Por exemplo:

Se o UI Button for pressionado, esta ação é igual a pressionar a tecla A do teclado. 

Como se fosse um botão de atalho, você pode clicar neste botão do teclado para realizar a ação, mas tbm pode clicar no botão UI para a mesma função   

Ficou um pouco confuso, espero que entendam.

VSouza
Membro
Membro

PONTOS : 2963
REPUTAÇÃO : 5
Respeito as regras : Joystick - Android WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Joystick - Android

Mensagem por VSouza Seg Jul 11, 2016 3:10 pm

Alguém sabe se o que está comentando neste forum funciona?

https://social.msdn.microsoft.com/Forums/windows/en-US/f1b195b7-1568-46f5-83bb-e1e85b188af2/how-to-simulate-a-key-press-in-c?forum=winforms

VSouza
Membro
Membro

PONTOS : 2963
REPUTAÇÃO : 5
Respeito as regras : Joystick - Android WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Joystick - Android

Mensagem por MarcosSchultz Seg Jul 11, 2016 7:48 pm

Depende do que você está tentando fazer... você pode mudar todos os inputs da Unity manualmente em Edit>ProjectSettings>Input

Mas pelo que eu entendi, basta criar um botão que chama uma void, e o input da letra chamar a mesma void...

MarcosSchultz
MarcosSchultz
Administrador

Masculino PONTOS : 64767
REPUTAÇÃO : 2651
Idade : 27
Áreas de atuação : Administrador do fórum
Respeito as regras : Joystick - Android Aad8pUi

https://www.schultzgames.com

Ir para o topo Ir para baixo

DÚVIDA Re: Joystick - Android

Mensagem por VSouza Ter Jul 12, 2016 9:40 am

Esse é o meu problema, se o Input chamasse uma função seria tranquilo, o problema que o código de movimentação não utiliza só uma função. 

Notei que o que depende do Input é a float hor, tentei criar uma função que igualasse a float hor positiva (1) ou negativa (-1), porém não funcionou. Sad

Segue código que estou tentando fazer essa troca de botões do teclado para Botões UI:


Código:
using UnityEngine;
using System.Collections;

namespace Acrocatic {
   // Enums for all classes.
   public enum Direction { Left, Right };

   // This class is used to communicate between the different Player movement classes.
   public class Player : MonoBehaviour {
      // Public variables that shouldn't be shown in the inspector.
      [HideInInspector]
      public float hor;                     // Get the Horizontal input.
      [HideInInspector]
      public bool facingRight;               // For determining which way the player is currently facing.
      [HideInInspector]
      public bool grounded = true;            // Whether or not the player is grounded.
      [HideInInspector]
      public bool walking = false;            // Determines if the player is walking.
      [HideInInspector]
      public bool stuckToWall = false;         // Used to stop the player from moving when stuck to a wall.
      [HideInInspector]
      public bool falling = false;            // Determines if the player is falling.
      [HideInInspector]
      public bool dashing = false;            // Determines if the player is dashing.
      [HideInInspector]
      public bool crouching = false;            // Determines if the player is crouching.
      [HideInInspector]
      public bool sliding = false;            // Determines if the player is sliding.
      [HideInInspector]
      public bool onLadder = false;            // Determines if the player is on a ladder.
      [HideInInspector]
      public GameObject frontCheckTop;         // A position marking to check if the player's front.
      [HideInInspector]
      public GameObject frontCheckBot;         // A position marking to check if the player's front.
      [HideInInspector]
      public Transform groundCheck;            // A position marking to check if the player is grounded.
      [HideInInspector]
      public Collider2D groundCollider;         // Ground collider object.
      [HideInInspector]
      public bool jumpDown = false;            // Determines if the player is about to jump down.
      [HideInInspector]
      public bool jumping = false;            // Determines if the player is jumping.
      [HideInInspector]
      public bool jumpingThrough = false;         // Determines if the player is jumping through a platform.
      [HideInInspector]
      public Rigidbody2D rigidbody;            // Cache the rigidbody of the player.
      
      // Public variables.
      [Tooltip("Select the direction in which the sprites are facing.")]
      public Direction spriteDirection;
      [Tooltip("Select the layer that should be used for platforms.")]
      public LayerMask platformLayer;
      [Tooltip("Select the layer that should be used for the ground.")]
      public LayerMask groundLayer;
      [Tooltip("Set the radius for the ground check. This creates a circle at the feet of the player, checking if anything from the ground or platform layer collides with the circle.")]
      public float groundRadius = 0.12f;
      [Tooltip("Enable or disable player rotation when on a rotated platform (slope).")]
      public bool rotateOnSlope = true;
      [Tooltip("Enable or disable player movement after death.")]
      public bool moveAfterDeath = true;
      [Tooltip("You can enable this to keep the player's velocity when hitting the ground. This is experimental and currently defaults to false.")]
      public bool keepVelocityOnGround = false;
      [Tooltip("The timer used for the remembering the player's velocity when hitting the ground. Don't give this a high value.")]
      public float groundedVelocityTime = 0.05f;

      // Private variables.
      private PlayerJump playerJump;            // Get the PlayerJump class.
      private PlayerWall playerWall;             // Get the PlayerWall class.
      private PlayerRun playerRun;             // Get the PlayerRun class.
      private PlayerCrouch playerCrouch;          // Get the PlayerCrouch class.
      private PlayerDash playerDash;             // Get the PlayerDash class.
      private PlayerHitbox playerHitbox;          // Get the PlayerHitbox class.
      private PlayerPlatform playerPlatform;      // Get the PlayerPlatform class.
      private Quaternion normalRotation;         // The default rotation for the player.
      private Animator animator;               // The player's animator.
      private bool flipAgain = false;            // Used to fix a bug.
      private float gravityScale;               // Cache the initial gravity scale.
      private bool isDead = false;            // Check if the player is dead.
      private float groundedXVelocity;         // Remember the X velocity when the player hits the ground.
      private float groundedTimer;            // Timer for how long the player should ignore the friction when hitting the ground.

      // Wall variables.
      private bool wallSliding = false;         // These variables are used to remember the wall sliding, running and jumping variables.
      private bool wallRunning = false;         // That's needed to show the correct animations.
      private bool wallJumping = false;

      // Use this for initialization.
      void Start () {
         // Setting up references.
         rigidbody = GetComponent<Rigidbody2D>();
         groundCheck = transform.Find("groundCheck");
         frontCheckTop = new GameObject("frontCheckTop");
         frontCheckBot = new GameObject("frontCheckBot");
         playerJump = GetComponent<PlayerJump>();
         playerWall = GetComponent<PlayerWall>();
         playerRun = GetComponent<PlayerRun>();
         playerCrouch = GetComponent<PlayerCrouch>();
         playerDash = GetComponent<PlayerDash>();
         playerHitbox = GetComponent<PlayerHitbox>();
         playerPlatform = GetComponent<PlayerPlatform>();
         normalRotation = transform.localRotation;
         animator = GetComponent<Animator>();
         gravityScale = rigidbody.gravityScale;
         
         // Set the frontCheck and backCheck transform parent to the player's transform.
         frontCheckTop.transform.parent = transform;
         frontCheckBot.transform.parent = transform;

         // Check which direction the player is facing based on the spriteDirection and flip when the spriteDirection is Left.
         if (spriteDirection == Direction.Right) {
            facingRight = true;
         } else {
            facingRight = false;
            Flip();
         }

         // Change the side marker positions.
         playerHitbox.ChangeSidePositions();
      }

      // This function is called every fixed framerate frame.
      void FixedUpdate() {
         // Set the player's hitbox.
         if (grounded && !dashing) {
            if (crouching) {
               ChangeHitbox("crouch");
            } else {
               ChangeHitbox("default");
            }
         } else {
            ChangeHitbox("jump");
         }

         // If the player is stuck to a wall or on a ladder.
         if (stuckToWall || onLadder) {
            // ... set the gravity scale to 0.
            rigidbody.gravityScale = 0;
         } else {
            // Reset the gravity scale.
            rigidbody.gravityScale = gravityScale;
         }

         // If the groundedXVelocity is active and keepVelocityOnGround is activated...
         if (keepVelocityOnGround && groundedXVelocity != 0) {
            // ... set the player's X velocity to the initial velocity when hitting the ground.
            SetXVelocity(groundedXVelocity);
         }
      }


      // Update is called once per frame.
      void Update() {
         // Cache the horizontal input.
         hor = Input.GetAxis("Horizontal");

         // Set the animator values.
         animator.SetBool("grounded", grounded);
         animator.SetBool("walking", walking);
         animator.SetBool("crouching", crouching);
         animator.SetBool("sliding", sliding);
         animator.SetBool("dashing", dashing);
         animator.SetBool("falling", falling);
         animator.SetBool("wall", stuckToWall);
         animator.SetBool("onLadder", onLadder);
         animator.SetBool("jumpingThrough", jumpingThrough);
         animator.SetFloat("horizontal", Mathf.Abs(hor));
         animator.SetFloat("xSpeed",  Mathf.Abs(rigidbody.velocity.x));
         animator.SetFloat("ySpeed", rigidbody.velocity.y);

         // The player is grounded if a circle at the groundcheck position overlaps anything on the ground layer.
         // Only perform the check if the player is not on a platform.
         if (!OnPlatform()) {
            groundCollider = Physics2D.OverlapCircle(groundCheck.position, groundRadius, groundLayer);
         }

         // If the groundedXVelocity is higher than 0 and keepVelocityOnGround is activated...
         if (keepVelocityOnGround && groundedXVelocity != 0) {
            // ... run the timer.
            if (groundedTimer > 0) {
               groundedTimer -= Time.deltaTime;
            } else {
               // Make sure the groundedXVelocity is set to 0.
               groundedXVelocity = 0;
            }
         }

         // If player is grounded and not jumping through a platform...
         if (groundCollider && !jumpingThrough) {
            // If the player isn't grounded yet and keepVelocityOnGround is activated...
            if (keepVelocityOnGround && !grounded) {
               // ... set the groundedXVelocity to the current X velocity.
               groundedXVelocity = rigidbody.velocity.x;
               // Start the groundedTimer.
               groundedTimer = groundedVelocityTime;
            }

            // Set grounded to true.
            grounded = true;
            // Set jumping to false.
            jumping = false;
            // Rotate player to collider's position if not on a platform.
            if (rotateOnSlope && !OnPlatform()) { transform.rotation = groundCollider.transform.localRotation; }
            // Call the stateComplete trigger if the player was falling.
            if (falling) {
               animator.SetTrigger("stateComplete");
            }
            falling = false;
         // Or else...
         } else {
            // ... rotate player to original position and set grounded to true.
            transform.rotation = normalRotation;
            grounded = false;
         }

         // If the player is moving in the opposite direction compared to the direction the player is facing...
         if((hor > 0 && !facingRight) || (hor < 0 && facingRight) || flipAgain) {
            // ... flip the player.
            Flip();
         }
      }

      // Make sure the player is dead.
      public void Dead() {
         isDead = true;
         SetJumps(0);
         falling = true;
         animator.SetTrigger("startFalling");

         // Disable player movement if it isn't allowed after death.
         if (!moveAfterDeath) {
            GetComponent<PlayerRun>().enabled = false;
         }
      }

      // ################
      // ### MOVEMENT ###
      // ###          ###
      // Function to flip the character.
      void Flip() {
         // Only flip the player when not dashing or sliding and the player isn't dead and not allowed to move while dead.
         if (!dashing && !sliding && !(isDead && !moveAfterDeath)) {
            flipAgain = false;

            // These if-statements are used to fix a bug where the player would be flipped before changing the animation.
            // This caused a weird flicker.
            AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(0);
            if (stuckToWall && (info.IsName("PlayerWallRun") || info.IsName("PlayerWallSlide"))) {
               flipAgain = true;
               if (playerWall.wallJump.enabled) {
                  animator.CrossFade("PlayerWallJump", 0f);
               } else {
                  animator.CrossFade("Jump/Fall", 0f);
               }
            } else if (!stuckToWall && info.IsName("PlayerWallJump")) {
               flipAgain = true;
            } else {
               // Switch the way the player is labelled as facing.
               facingRight = !facingRight;
               
               // Multiply the player's x local scale by -1.
               Vector3 theScale = transform.localScale;
               theScale.x *= -1;
               transform.localScale = theScale;
            }
         }
      }

      // Set the X velocity for the player.
      public void SetXVelocity(float xVel) {
         // If the player isn't grounded.
         if (!grounded) {
            // Check if the player is wall jumping and reset the variable if the player is wall jumping.
            bool isWallJumping = playerWall && playerWall.wallJump.enabled && playerWall.isWallJumping;
            if (isWallJumping)
               playerWall.isWallJumping = false;
         }

         // Set X velocity.
         rigidbody.velocity = new Vector2(xVel, rigidbody.velocity.y);
      }

      // Set the Y velocity for the player.
      public void SetYVelocity(float yVel) {
         rigidbody.velocity = new Vector2(rigidbody.velocity.x, yVel);
      }

      // Check if the player is allowed to change between walking and running while in the air.
      public bool CanWalkAndRunInAir() {
         if (playerJump) {
            return playerJump.airMovement.walkAndRun;
         } else {
            return true;
         }
      }

      // Check if the player was walking or running before jumping.
      public bool AirWalk() {
         return playerJump && playerJump.walkingOnJump;
      }

      // Get the player's air movement factor.
      public float GetAirSpeedFactor() {
         if (playerJump) {
            return playerJump.airMovement.speedFactor;
         } else {
            return 1.0f;
         }
      }

      // Function to set the walking variable.
      public void Walk(bool walk) {
         // Don't change the walking variable if the player is jumping and can't change from walking to running in the air.
         if (!grounded && playerJump && !playerJump.airMovement.resetOnWall && !CanWalkAndRunInAir())
            return;
         
         walking = walk;
      }

      // Get the speed.
      public float GetSpeed(bool withPlatform = true) {
         return playerRun.GetSpeed(withPlatform);
      }

      // Get the speed on a moving platform.
      public float GetSpeedOnMovingPlatform(float speed) {
         // If player is on a moving platform...
         if (OnMovingPlatform()) {
            // ... get the platform's X velocity.
            float xVel = GetPlatform().GetComponent<Rigidbody2D>().velocity.x;
            // If the player is moving left while the platform is moving to the left or when the player is moving to the right and the platform is moving to the right...
            if ((hor < 0 && xVel < 0) || (hor > 0 && xVel > 0)) {
               // ... add the platform's velocity to the speed of the player.
               speed = Mathf.Abs(xVel) + speed;
            // Or else if the player is moving to the right while the platform is moving to the left or when the player is moving to the left and the platform is moving to the right...
            } else if ((hor > 0 && xVel < 0) || (hor < 0 && xVel > 0)) {
               // ... make sure the player's speed is the platform's speed minus the normal speed.
               speed = Mathf.Abs(Mathf.Abs(xVel) - speed);
            } else if (hor == 0) {
               speed = Mathf.Abs(xVel);
            }
         }

         // Return the new speed.
         return speed;
      }

      // Get the player's speed in the air if movement in the air is using force.
      public float GetSpeedInAir(float speed) {
         // If the player isn't grounded.
         if (!grounded) {
            // Change the speed based on the boomerang X factor when the player is boomerang wall jumping.
            if (playerWall && playerWall.boomerangJump) {
               speed = speed * playerWall.wallJump.boomerangFactorX;
            // Or else change the speed based on the speed factor in the air.
            } else {
               speed = speed * GetAirSpeedFactor();
            }
         }

         // Return the speed.
         return speed;
      }

      // Use the change factor to determine the amount of control for the player.
      public float GetMovementForce(float force) {
         // If the player isn't grounded, not wall jumping and the force should be changed by a factor...
         if (!grounded && playerJump && playerJump.airMovement.changeFactor != 1.0 && !(playerWall && playerWall.wallJump.enabled && playerWall.isWallJumping)) {
            // ... set the new force.
            force = force * playerJump.airMovement.changeFactor;
         }
         // Return the force.
         return force;
      }
      // ###          ###
      // ################


      // #################
      // ### PLATFORMS ###
      // ###          ###
      // Unstick the player from the platform.
      public void UnstickFromPlatform() {
         playerPlatform.Unstick();
      }

      // Get the current platform.
      public GameObject GetPlatform() {
         return playerPlatform.currentPlatform;
      }

      // Check if the player is on a platform.
      public bool OnPlatform() {
         return playerPlatform.OnPlatform();
      }

      // Check if the player is on a moving platform.
      public bool OnMovingPlatform() {
         return playerPlatform.OnMovingPlatform();
      }
      
      // Check if the player is on a sinking platform.
      public bool OnSinkingPlatform() {
         return playerPlatform.OnSinkingPlatform();
      }

      // Check if the player is stuck to the platform.
      public bool IsStuckToPlatform() {
         return playerPlatform.IsStuckToPlatform();
      }
      
      // Check if the player is on a platform where the player is stuck to the X velocity.
      public bool IsStuckToPlatformX() {
         return playerPlatform.IsStuckToPlatformX();
      }

      // Return if the player should keep its speed when jumping from the platform.
      public bool KeepSpeedOnJump() {
         return playerPlatform.KeepSpeedOnJump();
      }
      // ###          ###
      // ################
      // ###          ###
      // ################


      // ###############
      // ### JUMPING ###
      // ###        ###
      // Change the total amount of jumps.
      public void SetJumps(int jumps) {
         if (playerJump) { playerJump.jumps = jumps; }
      }

      // Reset the total amount of jumps to the default value.
      public void ResetJumps() {
         if (playerJump) { SetJumps(playerJump.doubleJumping.totalJumps); }
      }

      // Make the player jump.
      public void Jump() {
         if (playerJump) { playerJump.InitJump(); }
      }

      // Make the player fall down.
      public void Fall() {
         SetJumps(0);
         falling = true;
         animator.SetTrigger("startFalling");
      }

      // Get the jump factor for the player.
      public float GetJumpFactor() {
         // Get the boomerang jump Y factor if the player is boomerang jumping.
         if (playerWall && playerWall.boomerangJump) {
            return playerWall.wallJump.boomerangFactorY;
         // Or else just return 1.0.
         } else {
            return 1.0f;
         }
      }
      // ###        ###
      // ###############


      // ############
      // ### WALL ###
      // ###      ###
      // Set the stuckToWall variable to make sure the player is stuck against a wall.
      public void StuckToWall(bool stuck) {
         stuckToWall = stuck;
      }

      // Set the wall sliding variables used by the animator.
      public void SetWallAnimation(bool run, bool slide, bool jump) {
         // Call the trigger 'stateComplete' when wall interaction is finished.
         if (((wallRunning && !run) || (wallSliding && !slide) || (wallJumping && !jump)) && !run && !slide && !jump) {
            animator.SetTrigger("stateComplete");
         }

         // Trigger the wall running animation when the player is wall running.
         if (run && !wallRunning) {
            animator.SetTrigger("startWallRun");
         }
         
         // Trigger the wall sliding animation when the player is wall sliding.
         if (slide && !wallSliding) {
            animator.SetTrigger("startWallSlide");
         }
         
         // Trigger the wall jumping animation when the player is wall jumping.
         if (jump && !wallJumping) {
            animator.SetTrigger("startWallJump");
         }

         // Set the wall interaction variables to remember what the player is doing.
         wallRunning = run;
         wallSliding = slide;
         wallJumping = jump;

         // Set the animator values for all wall interaction.
         animator.SetBool("wallRunning", run);
         animator.SetBool("wallSliding", slide);
         animator.SetBool("wallJumping", jump);
      }
      // ###      ###
      // ############


      // ###############
      // ### DASHING ###
      // ###        ###
      // Function to set the dashing variable.
      public void Dash(bool dash) {
         // Call the trigger 'stateComplete' when dashing is finished.
         if (dashing && !dash) {
            animator.SetTrigger("stateComplete");
         // Start the dash when dashing.
         } else if (dash && !dashing) {
            animator.SetTrigger("startDash");
         }
         dashing = dash;
      }

      // Function to reset the air dashing limit.
      public void ResetAirDashLimit() {
         if (playerDash) { playerDash.ResetAirDashLimit(); }
      }
      // ###        ###
      // ###############

      // ##############
      // ### HITBOX ###
      // ###        ###
      // Function to change the player's hitbox.
      public void ChangeHitbox(string type) {
         if (playerHitbox) { playerHitbox.ChangeHitbox(type); }
      }

      // Function to check if the player is allowed to stand up.
      public bool AllowedToStandUp() {
         return playerHitbox ? playerHitbox.AllowedToStandUp() : true;
      }
      // ###        ###
      // ##############

      // #################
      // ### CROUCHING ###
      // ###          ###
      // Function to set the crouching variable based on if the player is crouching.
      public void Crouch(bool crouch) {
         crouching = crouch;
      }
      // Function to set the sliding variable based on if the player is sliding.
      public void Slide(bool slide) {
         // Call the trigger 'startSlide' when sliding.
         if (!sliding && slide) {
            animator.SetTrigger("startSlide");
         }
         sliding = slide;
      }
      // Function to get the crouch speed.
      public float GetCrouchSpeed() {
         if (playerCrouch) {
            return playerCrouch.crouchSpeed;
         } else {
            return 0;
         }
      }
      // ###          ###
      // #################

      // #################
      // ### CROUCHING ###
      // ###          ###
      public void OnLadder() {
         onLadder = true;
         animator.SetTrigger("triggerLadder");
      }
      // ###          ###
      // #################
   }
}

VSouza
Membro
Membro

PONTOS : 2963
REPUTAÇÃO : 5
Respeito as regras : Joystick - Android WvDYdlf

Ir para o topo Ir para baixo

DÚVIDA Re: Joystick - Android

Mensagem por MarcosSchultz Qua Jul 13, 2016 7:18 pm

OK, o problema é que você tem que optar por um input predominante, exemplo:

você aperta 'esquerda' no teclado, mas nos botões você aperta 'direita', o que você pretende que aconteça neste caso?
MarcosSchultz
MarcosSchultz
Administrador

Masculino PONTOS : 64767
REPUTAÇÃO : 2651
Idade : 27
Áreas de atuação : Administrador do fórum
Respeito as regras : Joystick - Android Aad8pUi

https://www.schultzgames.com

Ir para o topo Ir para baixo

DÚVIDA Re: Joystick - Android

Mensagem por VSouza Qui Jul 14, 2016 1:18 pm

Decidi refazer o código de movimentação eu mesmo, esse veio em um asset da asset Store, fiz um eu mesmo que ai faço do meu jeito.

VSouza
Membro
Membro

PONTOS : 2963
REPUTAÇÃO : 5
Respeito as regras : Joystick - Android WvDYdlf

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos