Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Frostyx · Sep 14, 2015 at 10:08 AM · 2dmovementnot workingrpg

Character Not Moving RPG Game

Hi all,

I have been not working on this project for a long time, but I remember the last time I was, the character was moving. Now, when I try to move, the animator works, but the movement (or the translation of the character and camera) are not working. What I tried: - Fixing the script's 2D vector, which seemed to be fine, as shown in the code. - Fix Input from Edit > Project Settings, which only had one error, where the vertical was assigned to the x-axis, but I did fix it and nothing has happened. The negative alts are assigned correctly to WASD. - Check Animator Apply Root Motion option, which is not ticked.

Following is the script of the movement that I have attached to the RPG Character. The game is sort of Pokemon-like:

 using UnityEngine;
 using System.Collections;
 using System.Text.RegularExpressions;
 
 public class Movement : MonoBehaviour
 {
     //GOING TO DO MAJOR CHANGES STARTING NOW!
     public Vector2 speed = new Vector2(50, 50);
     public string TagName;
     private treeHeal th;
     public bool canIMove;
     private Vector2 movement;
     public AudioSource backgroundAudio;
     public AudioSource fireStageBackgroundAudio;
     public AudioSource getHealed;
     public AudioSource walkingSound1;
     private Animator animator;
     private bool wisDown = false;
     private bool sisDown = false;
     private bool aisDown = false;
     private bool disDown = false;
     private bool walkingSound;
     private int counter = 0;
     #region for fire monster king checking his death to toggle this
     //In here, I have done the assignment of death of the fire monster, what I need to do now is not be able to pass another stage if the fire boss hasn't died
     private bool FireSkeletonMonsterBossDeathRecord = false;
     private MonsterHealthScript checkDeath;
     #endregion
     public bool fireStageTrigger;
     void Start(){
         canIMove = true;
         if (fireStageTrigger == true) {
             fireStageBackgroundAudio.Play ();
         } else {
             backgroundAudio.Play ();
         }
 
     }
 
     void Update()
     {
 
         // 3 - Retrieve axis information
         //Previously, it was GetAxis(), however that adds interia
         //We removed GetAxis and replaced it with GetAxisRaw to remove the inertia
         float inputX = Input.GetAxisRaw ("Horizontal");
         float inputY = Input.GetAxisRaw ("Vertical");
         // 4 - Movement per direction
         if (checkDeath.enemyhp <= 0) {
             FireSkeletonMonsterBossDeathRecord = true;
         }
         getCanIMove ();
         if (canIMove == false) {
             if (fireStageTrigger == true) {
                 fireStageBackgroundAudio.Stop ();
             } else {
                 backgroundAudio.Stop ();
             }
         }
             movement = new Vector2 (
                 speed.x * inputX,
                 speed.y * inputY);
         if (Input.GetKeyDown ("w")) {
             walkingSound1.loop = true;
             walkingSound1.Play();
             wisDown = true;
             disDown = false;
             aisDown = false;
             sisDown = false;
 
         }
         else if (Input.GetKeyDown ("d")) {
             walkingSound1.loop = true;
             walkingSound1.Play();
             wisDown = false;
             disDown = true;
             aisDown = false;
             sisDown = false;
         }
 
         else if (Input.GetKeyDown ("s")) {
             walkingSound1.loop = true;
             walkingSound1.Play();
             wisDown = false;
             disDown = false;
             aisDown = false;
             sisDown = true;
         }
         else if (Input.GetKeyDown ("a")) {
             walkingSound1.loop = true;
             walkingSound1.Play();
             walkingSound = true;
             wisDown = false;
             disDown = false;
             aisDown = true;
             sisDown = false;
         }
         else if (Input.GetKeyUp ("w")) {
             walkingSound1.loop = false;
         }
         else if (Input.GetKeyUp ("a")) {
             walkingSound1.loop = false;
         }
         else if (Input.GetKeyUp ("s")) {
             walkingSound1.loop = false;
         }
         else if (Input.GetKeyUp ("d")) {
             walkingSound1.loop = false;
         }
     
 
 
     }
     public bool getCanIMove(){
         return canIMove;
 
     }
     public IEnumerator treeWaiterFunction(){
         yield return new WaitForSeconds (2.5f);
         canIMove = true;
         if (fireStageTrigger == true) {
             fireStageBackgroundAudio.Play ();
         } else {
             backgroundAudio.Play ();
         }
     }
 
     void OnTriggerEnter2D(Collider2D otherCollider){
 
         if (Regex.IsMatch (otherCollider.tag, "Monster", RegexOptions.IgnoreCase)) {
             canIMove = false;
             if (fireStageTrigger == true) {
                 fireStageBackgroundAudio.Stop ();
             } else {
                 backgroundAudio.Stop ();
             }
 
         } else if (otherCollider.tag == "Tree") {
             canIMove = false;
 
             treeHeal myTree = otherCollider.gameObject.GetComponent<treeHeal> ();
             if (fireStageTrigger == true) {
                 fireStageBackgroundAudio.Stop ();
             } else {
                 backgroundAudio.Stop ();
             }
             myTree.healParticle.Play ();
             myTree.treeTheme.Play ();
             gameObject.GetComponent<PlayerHealthScript> ().playerhp = 100;
             StartCoroutine (treeWaiterFunction ());
 
         } else if (otherCollider.tag == "NPC") {
             canIMove = false;
 
             
         } else if (otherCollider.tag == "FireSkeletonMonsterBoss") {
             checkDeath = otherCollider.gameObject.GetComponent<MonsterHealthScript>();
         }
             
         
 
         else {
             canIMove = true;
         }
 
     }
     void FixedUpdate()
     {
         // 5 - Move the game object
         if (canIMove == true) {
             GetComponent<Rigidbody2D> ().velocity = movement;
         } else if (canIMove == false) {
         
             Vector2 temp = new Vector2(0,0);
             GetComponent<Rigidbody2D>().velocity = temp;
         }
     
     }
 }


It is really bugging me. I wish I could fix it. Think it could be a unity thing?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Best way to spell hit a target 2D tile based game. 1 Answer

Grid Movement VS Free Movement 1 Answer

Player moves to the middle of the room when the level starts (2d point and click) 2 Answers

moving object toward waypoint and alignment 0 Answers

2D Movement and getting the mouse position 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges