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 gtagamer · Aug 17, 2015 at 05:04 AM · movementsprite

How to make a basic 2d movement script for a 3d game

hello,i was making a 3d game but the character in the game is a 2d sprite and i want the sprite to have a 2d left to right walk and a jump movement script on it and the script that i put on my sprite dosent work to well because it has rigidbody and when an object has rigidbody body is needs a collider or else its gonna fall through other object so when i put a collider on my sprite it dosent go on my sprite to well and the sprite cant walk right how can i make it to where i don't need rigidbody for my sprite to walk and how can i add a jump movement to my script.

 using UnityEngine;
 using System.Collections;
 
 public class movement : MonoBehaviour {
 
     public float speed;
     
     void Awake () {
         
     }
     
     void FixedUpdate () {
         
         if (Input.GetKey("a")) {
             GetComponent<Rigidbody>().AddForce (-Vector3.right * speed * Time.deltaTime);
         }
         if (Input.GetKey("d")) {
             GetComponent<Rigidbody>().AddForce (Vector3.right * speed * Time.deltaTime);
         }
     }
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kevinspawner · Aug 17, 2015 at 07:59 AM

  1. You need to replace the Rigidbody with Rigidbody 2D in your script.

  2. Replace the Rigid body component in your inspector with Rigidbody2D.

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 gtagamer · Aug 17, 2015 at 12:19 PM 0
Share

thanks that solve one problem now how can i get my sprite to jump

avatar image kevinspawner · Aug 18, 2015 at 03:04 AM 0
Share

Link: http://answers.unity3d.com/questions/798998/i-only-want-my-character-to-jump-when-touching-the.html

You can mark the answer as completed if it solves your problem.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Sprite animation 2 Answers

Saving Rotation of Sprite 1 Answer

Problem with mooving sprites 1 Answer

Sprite flip movement script not working! HELP! 0 Answers

Changing sprite depending on movement direction 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