Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Allie_98 · May 21, 2015 at 09:16 AM · c#rigidbodyvelocityspace shooter

When I am coding in C# for my player to move in space shooter rigidbody.velocity = movement; refuses to be recognized. Why? and what can i do to fix this?

 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour
 {
     
     void FixedUpdate()
     {
         float moveHorizontal = Input.GetAxis("Horizontal");
         float moveVertical = Input.GetAxis("Vertical");
 
         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical)
         rigidbody.velocity = movement;
     }
 }
 

The last line of code rigidbody.velocity = movement; is not recognized by unity. I followed every single step that the tutorial told me to do and I have checked the done examples and my friends have looked it over and so has my teacher. No one understands why it won't work. I have re-created my Unity space shooter game for the second time. I do not understand what I have done wrong. PLEASE HELP!!!!

Here is the tutorial i was following to move my player. I have everything he does except my game won't run and it does not register my "rigidbody.velocity".... Space Shooter - Unity - Moving the Player

Comment
Add comment · Show 2
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
avatar image spiceboy9994 · May 21, 2015 at 01:49 PM 0
Share

Do your game object have a rigidbody?, what do you meant with "not recognized", what is the error that you receive at the console window?

avatar image maccabbe · May 21, 2015 at 01:55 PM 0
Share

http://docs.unity3d.com/ScriptReference/GameObject-rigidbody.html

http://docs.unity3d.com/ScriptReference/Rigidbody-velocity.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Baste · May 21, 2015 at 02:41 PM

Are you using Unity 5?

Unity 5 deprecated the .rigidbody variable, as it wasn't obvious that it did a .GetComponent behind the scenes.

Replace this:

 rigidbody.velocity = movement;

with:

 GetComponent<rigidbody>().velocity = movement;

Unity should have asked you to update that automatically for you, and the error message should have mentioned that "UnityEngine.Component.rigidbody' is obsolete: `Property rigidbody has been deprecated. Use GetComponent() instead."

Comment
Add comment · Share
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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Velocity powered rigidbody on a moving platform without parenting. 3 Answers

Space Shooter tutorial shot velocity issues 0 Answers

rigidbody.velocity.normalized application 1 Answer

Is there a way to set velocity while setting the position? 1 Answer

Velocity of multiple rigidbody obiects in array 4 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