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 donsavage · Dec 12, 2014 at 09:14 AM · movementroll a ballorigin

Weird bug. Roll a ball project

I'v been working on the roll-a-ball project from the learn section. I recently added a "Speed" text field and I noticed that when I first start playing, if press W or S then the speed will not go above 3.8 (or below -3.8). If I go left or right just a hair, this will fix the problem and I can move with W and S as normal. The same fix happens if I bump the ball into a wall. The glitch also does not occur if I start the ball out at (.1, .5, 0) in the editor instead of (0, .5, 0). Just incase I somehow screwed the code up I'll paste it below.

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour {
     public float moveSpeed;
     public float accelSpeed;
     private int pickupCount;
     public Text countText;
     public Text winText;
     public Text speedGage;
 
     void Start(){
         pickupCount = 0;
         setCountText();
         winText.text = "";
         speedGage.text = "0";
     }
     void FixedUpdate(){
         updateMovement();
 
     }
     void updateMovement(){
         float moveHorizontal = Input.GetAxis("Horizontal");
         float moveVertical = Input.GetAxis("Vertical");
         Vector3 movement = new Vector3(moveHorizontal,0,moveVertical);
         rigidbody.AddForce(movement * moveSpeed * Time.deltaTime);
         speedGage.text = rigidbody.velocity.ToString();
     }
     void OnTriggerEnter(Collider other){
         if(other.gameObject.tag == "PickUp"){
             other.gameObject.SetActive(false);
             pickupCount += 1;
             setCountText();
         }
     }
     void setCountText(){
         countText.text = "Count: " + pickupCount.ToString();
         if(pickupCount == 16){
             winText.text = "You Win!";
         }
     }
 }

Comment
Add comment · Show 3
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 NicRule · Dec 12, 2014 at 05:57 PM 0
Share

Your problem is probably in the level. $$anonymous$$aybe a collier you deleted the renderer on which is blocking the ball. Try building a new scene and placing only the ball and a platform in it. The script looks right to me. I don't know why you put the movement information in it's own script ins$$anonymous$$d of directly in fixed update. That's just making things very slightly less efficient.

avatar image donsavage · Dec 12, 2014 at 06:18 PM 0
Share

It's not that. There are only 5 or so items in the hierarchy, of which none are touching the player. I also tried moving the x to .000000001 ins$$anonymous$$d of 0. It still works perfectly. I doubt something like this would avoid a collider.

avatar image NicRule · Dec 12, 2014 at 08:29 PM 0
Share

In that case I would guess it's just a bug. You're not doing anything wrong as far as I can tell. $$anonymous$$aybe someone else can figure it out. Sorry.

0 Replies

· Add your reply
  • Sort: 

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Using WASD keys instead of mouse to roll ball? 1 Answer

Animation Movement 1 Answer

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

Adding a script in Editor moves GameObjects back to Origin. 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