- Home /
My Character doesnt move since ive put aim
i'm using unity 2019 4.1 and since i've put an aim to my Character's crossbow he doesnt move anymore. Here are the scripts:
PlayerMovements:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerMovements : MonoBehaviour { public Animator animator; public GameObject Target;
 void Update()
 {
     Vector3 movement = new Vector3(Input.GetAxis("Horizontal"),Input.GetAxis("Vertical"), 0.0f);
     if (Input.GetButton("Fire1"))
     {
         Debug.Log("FIRE!");
     }
     MoveTarget();
     animator.SetFloat("Horizontal", movement.x);
     animator.SetFloat("Vertical", movement.y);
     animator.SetFloat("Magnitude", movement.magnitude);
     transform.position = transform.position + movement * Time.deltaTime; 
 }
 private void MoveTarget()
 {
     Vector3 aim = new Vector3(Input.GetAxis("TargetX"), Input.GetAxis("TargetY"), 0.0f);
     if (aim.magnitude > 0.0f)
     {
         aim.Normalize();
         aim *= 0.4f;
         Target.transform.localPosition = aim;
         Target.SetActive(true);
     }
     else
     {
         Target.SetActive(false);
     }
 }
} 
 XboxMovements: 
 using System.Collections; using System.Collections.Generic; using UnityEngine;
public class XboxMovements : MonoBehaviour { public Animator animator; public GameObject Target;
 void Update()
 {
     Vector3 movement = new Vector3(Input.GetAxis("MoveHorizontal"),Input.GetAxis("MoveVertical"), 0.0f);
     if (Input.GetButton("Fire3"))
     {
         Debug.Log("FIRE!");
     }
     animator.SetFloat("Horizontal", movement.x);
     animator.SetFloat("Vertical", movement.y);
     animator.SetFloat("Magnitude", movement.magnitude);
     transform.position = transform.position + movement * Time.deltaTime; 
 }
private void MoveTarget() { Vector3 aim = new Vector3(Input.GetAxis("TargetX"), Input.GetAxis("TargetY"), 0.0f);
     if (aim.magnitude > 0.0f)
     {
         aim.Normalize();
         aim *= 0.4f;
         Target.transform.localPosition = aim;
         Target.SetActive(true);
     }
     else
     {
         Target.SetActive(false);
     }
 }
}
Your answer
 
 
             Follow this Question
Related Questions
Character Flying around uncontrollably 2 Answers
Any good FPS Character Controller Script? 1 Answer
Player inversed inputs 0 Answers
Enemy Character Controller 1 Answer
Mecanim and Child Objects 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                