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 /
  • Help Room /
avatar image
0
Question by Cubemaster · Nov 16, 2015 at 08:41 AM · unity 53dcharactergeneral

How do I get a character to move (Without the default scripts, which don't seem to work)?

I'm basically making a test/joke game, so I don't care about the details too much, just want to make something actually happen. This is my first time trying to use Unity. The character is a rectangular prism with no animations. I have a rigidbody, a box collider, and the script "moving better hopefully", which I found online (I named it though)

using UnityEngine; using System.Collections;

public class movingBetterHopefully : MonoBehaviour {

 public float speed;
 
 private Rigidbody rb;
 
 void Start ()
 {
     rb = GetComponent<Rigidbody> ();
 }
 
 void FixedUpdate ()
 {
     float moveHorizontal = Input.GetAxis ("Horizontal");
     float moveVertical = Input.GetAxis ("Vertical");
     
     Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
     
     rb.AddForce (movement * speed);
 }

}

(Sorry for the formatting...)

I can set the inputs when I build the game, but the character can't actually move. What do I need to do here? Thanks in advance, and sorry for being pretty ignorant about the whole process... I've been trying to get this working for probably a week now and getting pretty frustrated.

Comment
Add comment · Show 1
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 Cherno · Nov 16, 2015 at 09:20 AM 0
Share

The first thing you should do is insert Debug.Log lines and/or put the movement variable into the main body of the script and make it public so it's values are seen in the inspector. That lets you check if there's actually any movement happening in theory. Same goes for the Axis... Check if their values actually change on input.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by ZeraTFK · Nov 16, 2015 at 10:21 AM

What is your Speed value? If the value equal 0 then it wont move. if the value less then ~10.. 15.. and the Mass of your Rigidbody is 1 then it move very very very very slow until nothing.

Be sure the Speed is != 0 and Lower the Mass || increase the speed * 10 or 100

Comment
Add comment · Show 2 · 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
avatar image ZeraTFK · Nov 16, 2015 at 12:02 PM 0
Share

I add a example to download $$anonymous$$oveArrowRigidbodyForce

avatar image Cubemaster · Nov 16, 2015 at 09:16 PM 0
Share

That was the issue, turns out my speed was only set to 1... :P Thanks for the help!

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

6 People are following this question.

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

Related Questions

How do you stop capsule from going through walls? 1 Answer

How do I optimize my code?,How do I optimize my script? 1 Answer

How do i calculate mesh on a spline?? 0 Answers

[SOLVED] In game narration system 1 Answer

How can I make a game similar to Lego Universe (sort of like a replica) 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