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 Wrockies · Aug 30, 2015 at 05:50 PM · c#movementobjectjumping object

How can I make an object in my scene jump continuously?

Hello Unity people! I am currently working on a game that will have the player collecting object in the level. I wont get into detail as its not important. I will have objects in the scene the player is collecting, in this case I want it to be a sheep. For testing purposes, the "sheep" is currently just a cube, and I have it moving around in a circle. However, I want it to continuously jump as well as it moves around. using UnityEngine; using System.Collections; public class Movement : MonoBehaviour { %|1007631654_1|% } void Update () { transform.Translate (new Vector3 (1, 0, 0) * Time.deltaTime); transform.Rotate (new Vector3 (0, 45, 0) * Time.deltaTime); %|-1896819847_6|% }

That is what I have for moving the "sheep" (cube) in a circle. I tried simply adding another line to the update: "transform.Translate (new Vector3 (0, 3, 0) * Time.deltaTime);". However, it would jump a couple times like this then would glitch like crazy landing on it side and flying into the walls. Anybody know how I could make the cube continuously jump? Thanks in advance!

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 Wrockies · Aug 29, 2015 at 06:41 PM 0
Share

Sorry about the % and numbers... ignore them, some sort of formatting issue must have occurred. They do not exist in my script.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by satyagames · Aug 31, 2015 at 11:13 AM

 using UnityEngine;
 using System.Collections;
 
 public class rotateScript : MonoBehaviour {
     
     public float minRotationSpeed = 80.0f;
     public GameObject pivot;
 
     bool grounded; 
     void Start() { 
 
     }
     
     void Update() {
         transform.RotateAround(pivot.transform.position, Vector3.up, minRotationSpeed * Time.deltaTime);
 
         if (grounded)
         {
             transform.Translate(Vector3.up * 2 * Time.deltaTime, Space.World);
            } 
     }
 
     void OnCollisionEnter(Collision collision) {
         if (collision.gameObject.tag == "ground") {
             grounded = true;
         } else {
             grounded = false;        
         }
     }
 }

alt text

alt text


sheep.png (324.7 kB)
ground.png (234.0 kB)
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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Making a bubble level (not a game but work tool) 1 Answer

Distribute terrain in zones 3 Answers

making an object move to a certain point 3 Answers

How can I restrict player movement to the edges of the plane so that they don't fall off the platform? 2 Answers

Simple way to make an object go up and down?(Y axis) 1 Answer


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