Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 johnsczx · Jun 22, 2020 at 03:00 PM · physicstransformvuforia

rigid body can rotate but will not move

Hello Unity forums (: I am trying to build a vuforia AR game. I followed this guide: https://www.youtube.com/watch?v=khavGQ7Dy3c And succeeded in making it fully functional, with the character walking around(using .velocity) and rotating to face the direction it moves in(using .transform.eulerAngles). However, once I swapped out the character model for a different model(In my case, a beating heart), the replacement model could still move around but could no longer rotate. I tried changing the model scale (.transform.localScale) but that didnt work either. It seems that the rb.velocity still functions normally but not the rb.transform.localScale or rb.transform.eulerAngles methods. I remembered to attach a rigid body component to the new model and also to drag them into the appropriate inspector boxes. Please send help i am out of ideas. Here is my code, just in case yall wanna look at it. Note that there are some really lame questionable things I did in the code like converting a byte into a string then into an int then into a float. But for now I need to solve the most pressing issue which is the transform not working.

thank you so much for your help ((':

 using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  public class overseer : MonoBehaviour
  {
      public Text txt;
      public GameObject character;
      public GameObject SpawnPoint;
  
      public GameObject Plane;
  
      public Rigidbody rb;
      public Animation anim;
      byte[] BLEin = new byte[4]{0,0,0,0};
      int inInt;
      float inFloat;
      string inString;
      public textChanger00 textChanger00;
  
      float x = 0;
      float y = 0;
     // float z = 0;
  
      float angle;
  
      
      // Start is called before the first frame update
      void Start()
      {
          rb = character.GetComponent<Rigidbody>();
          anim = character.GetComponent<Animation>();
          textChanger00 = GameObject.FindObjectOfType<textChanger00>();
         // character.transform.position = new Vector3(0f,1f,-6f);
         // rb.transform.position = new Vector3(0f,0f,0f);
      }
      void FixedUpdate()
      {
          Vector3 movement = new Vector3 (x,-0.05f,y);
          rb.velocity = movement * 4f;
      }
  
      // Update is called once per frame
      
      void Update()
      {
          BLEin = textChanger00.getBytes();
          //inFloat = System.BitConverter.ToSingle(BLEin,0);
          //inInt = System.BitConverter.ToInt32(BLEin,0);
          //Debug.Log(System.BitConverter.getBytes(BLEin));
          //inInt = int.Parse(BLEin);
          //txt.text = System.Convert.ToBase64String(textChanger00.getBytes());
         // txt.text = Encoding.Default.GetString(textChanger00.getBytes());
        // txt.text = System.BitConverter.ToString(textChanger00.getBytes()); //works!
         // txt.text = System.BitConverter.ToString(BLEin); // this also works
  
          inString = System.BitConverter.ToString(BLEin);
          inInt = System.Int32.Parse(inString, System.Globalization.NumberStyles.HexNumber); // aw shit this works. its stupid but it works
          inFloat = inInt/10;
          //txt.text = inString;
  
          //Debug.Log(inInt);
  
          //TEST CODE START HERE
         // Vector3 scale = new Vector3 (inFloat,inFloat,inFloat);
         // rb.transform.localScale = scale;
          //TEST CODE END HERE
  
  
  
        //okay so this works. the in the byte array, when working from 0 to 5, only 0th index changes 
         
         switch (BLEin[0])
         {
             case 1:
              txt.text = "UP";
              y = 1;
              x = 0;
              
              angle = 0;
            //  anim.Play("walk");
             break;
  
             case 2:
              txt.text = "DOWN";
              y = -1;
              x = 0;
              
              angle = 180;
             // anim.Play("walk");
             break;
  
             case 3:
              txt.text = "LEFT";
              x = -1;
              y = 0;
              
              angle = -90;
            //  anim.Play("walk");
             break;
  
             case 4:
              txt.text = "RIGHT";
               x = 1;
              y = 0;
              
              angle = 90;
            //  anim.Play("walk");
             break;
  
             case 5:
              txt.text = "A";
             break;
  
             case 6:
              txt.text = "B";
              x = 0;
              y = 0;
              
  
             break;
  
  
             default:
              txt.text = " ";
              x = 0;
              y = 0;
              
            //  anim.Play("idle");
             // rb.velocity = Vector3.zero;
             // rb.Sleep();
             break;
         }
  
  
  
         Vector3 movement = new Vector3 (x,0,y); // no y component because not moving up and down
          
          rb.velocity = movement * 4f;
          rb.transform.eulerAngles = new Vector3(0,angle,0);
  
          if (rb.transform.position.y < Plane.transform.position.y - 2)
          {
              rb.transform.position = SpawnPoint.transform.position;
  
          }
          
  
  
  
      }
  
      
  }
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

237 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Continue object in the current direction of travel 2 Answers

Rigidbody is behaving abnormally when transformed manually 0 Answers

Strange Physics being applied to objects issue. 1 Answer

ignorecollision return error 0 Answers

Moving child transform also moves parent rigidbody 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