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 MattDollar · Jan 19, 2016 at 04:50 AM · c#floatvaluesnew usertutorials-start-scripting

Unity c# not recognizing Float as a Value Type, the script is identical to tutorial but the game still bugs out

I'm new to Unity so I'm starting small with a tutorial on how to make PONG. This is the tutorial I was using: https://www.youtube.com/watch?v=jEeT23Rc0P0

I've quadruple checked my code but it is identical to his in the video. The only difference I could find is that the Float value type is green in mine and blue in his. I figured out that when typing out "float" the auto fill box only lists it as a keyword while in the video it's marked as a value type. The same thing applies to the type "Int". I'm not sure if this is what is causing the game to bug out but it doesn't make sense that I've copied it exactly and I'm getting different results.

The bug is the same as his at the end of the video in that the paddle doesn't move smooth along the y axis with the up and down arrows but flickers back and forth from the top to the bottom. Even after I made the change that should have fixed it mine still had the bug.

This is the code I'm using and It's a component on the Paddle sprite:

using UnityEngine; using System.Collections; public class Paddle : MonoBehaviour {

 public float paddleSpeed = 1F;
 public Vector3 playerPos = new Vector3(0,0,0);
 void Update () 
 {
     float yPos = gameObject.transform.position.y + (Input.GetAxis("Vertical") * paddleSpeed);
     playerPos = new Vector3 (-20,Mathf.Clamp(yPos, 11,-11),0);
     gameObject.transform.position = playerPos;
 }

}

Not sure what to do about this, trying to learn C# so I can make a game I've been wanting to make for a while now. This is just a frustrating road block that I hope someone can help me fix it.

Any help is greatly appreciated.

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 bubzy · Jan 19, 2016 at 08:22 AM 0
Share

i would use lerp for movement like this

http://docs.unity3d.com/ScriptReference/Vector3.Lerp.html

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Fulacine · Jan 19, 2016 at 08:36 AM

the Negative is on the wrong 11 put the negative on the first 11 playerPos = new Vector3 (-20,Mathf.Clamp(yPos, -11,11),0);

I check out the video and tried your code out and this was the problem. @ MattDollar

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 bubzy · Jan 19, 2016 at 08:40 AM 0
Share

sadly this wont make a difference, you have already told the complier that this is a floating point value with the 'f', what could work though is making that value smaller say 0.1f

avatar image
0

Answer by MattDollar · Jan 19, 2016 at 02:43 PM

It's working now but I don't know why.

I know for a fact I made that change and I thought that's the code I put in the question. Not sure what the deal is but I'm glad it's working now. maybe I just didn't save it properly when I fixed it. Oh well. Thanks for the help.

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 Fulacine · Jan 19, 2016 at 04:53 PM 0
Share

vote me up so i get rep

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

62 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

Related Questions

why doesnt change my money float? 2 Answers

Get Temperature Value and Prompt an Action 0 Answers

Can you do float + float 1 Answer

How to convert User Values into degree(Angle)?? 2 Answers

Is my MonoDeveloped Glitchd ??? 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