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 nemesis619 · Dec 22, 2018 at 10:29 AM · controllerjumpingmoveball

i want to move a ball on z axis and jump on y axis ,

i'am new to unity and want to make game where ball is moving and want to jump when we touch the platform on which it is moving. please help

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 nemesis619 · Dec 22, 2018 at 10:37 AM 0
Share

this is the code which iam using

using System; using System.Collections; using System.Collections.Generic; using UnityEngine;

public class BallController : $$anonymous$$onoBehaviour { public float force = 100000f; public float jump =50000f; public Rigidbody rb;

 void Start()
 {
     rb = GetComponent<Rigidbody>();
 }

void FixedUpdate() { rb.AddForce(0, 0, Time.deltaTime * force);

 }
 private void Update()
 {
     if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space))
     {
         rb.AddForce(0, jump * Time.deltaTime, 0) ;
     }
 }


}

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by hexagonius · Dec 22, 2018 at 10:42 AM

the are several Tutorials out there, you should check them out, especially this one:
https://unity3d.com/de/learn/tutorials/s/roll-ball-tutorial

Comment
Add comment · Show 1 · 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 nemesis619 · Dec 22, 2018 at 10:50 AM 0
Share

i could not find tutorial helpful it just tells how to move the balls, can you please check my code and tell where iam wrong

avatar image
0

Answer by GamitusLabs · Dec 22, 2018 at 03:50 PM

I'm not sure which AddForce you are using, this overload is the most basic: AddForce(Force, Mode)

Example: AddForce(Vector3.up * force, ForceMode.Impulse);


For a more in depth explanation on the modes: https://docs.unity3d.com/ScriptReference/ForceMode.html


A few other notes:

  1. Your force values are insanely high and when you get it working you're probably going to see your object just disappear.

  2. Apply your physics forces in FixedUpdate to keep the application of forces normalized.

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

103 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

Related Questions

Ball Rolling Game Help 0 Answers

move character controller with collision 3 Answers

how can I make the character jump more by holding the jump button in this script? 1 Answer

Character fall animation 1 Answer

How can i move a 2D ball ? 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