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
1
Question by MrBackstabby · Oct 06, 2016 at 07:48 AM · 2d2d game2d-gameplay

Some more errors: CS0117, CS1502, CS1503, CS0162

In my code I get the errors:

Assets/2d prefabs/Scripts/Move2.cs(59,102): error CS0117: UnityEngine.PointEffector2D' does not contain a definition for position'

Assets/2d prefabs/Scripts/Move2.cs(59,68): error CS1502: The best overloaded method match for UnityEngine.Physics2D.OverlapCircleAll(UnityEngine.Vector2, float, int)' has some invalid arguments
Assets/2d prefabs/Scripts/Move2.cs(59,68): error CS1503: Argument #1' cannot convert object' expression to type UnityEngine.Vector2'

Assets/2d prefabs/Scripts/Move2.cs(64,55): warning CS0162: Unreachable code detected

My code is: using UnityEngine; using System.Collections;

 public class Move2 : MonoBehaviour {
     private Rigidbody2D myRigidbody;
     [SerializeField]
     private float movementSpeed;
     [SerializeField]
     private Transform[] groundPoints;
     [SerializeField]
     private float groundRadius;
     [SerializeField]
     private LayerMask whatIsGround;
 
     private bool isGrounded;
 
     private bool jump;
     [SerializeField]
     private float jumpForce;
     // Use this for initialization
 
     void Start ()
     {
         myRigidbody = GetComponent<Rigidbody2D>();
     }
     
     // Update is called once per frame
     void FixedUpdate ()
     {
         isGrounded = IsGrounded ();
         float horizontal = Input.GetAxis ("Horizontal");
         Debug.Log ("Horizontal");
 
         HandleMovement (horizontal);
     }
     private void HandleMovement(float horizontal)
     {
         myRigidbody.velocity = new Vector2 (horizontal * movementSpeed,  myRigidbody.velocity.y);
 
         if (isGrounded && jump)
             isGrounded = false;
         myRigidbody.AddForce (new Vector2 (0, jumpForce));
     }
     private void HandleInput()
     {
         if(Input.GetKeyDown(KeyCode.UpArrow)) 
         {
             jump = true;
         }
     }
     private void ResetValues()
     {
         jump = false;
     }
     private bool IsGrounded()
     {
         if (myRigidbody.velocity.y <= 0) {
             foreach (Transform point in groundPoints) {
                 Collider2D[] colliders = Physics2D.OverlapCircleAll (PointEffector2D.position, groundRadius, whatIsGround);
             
                 for (int i = 0; i < colliders.Length; i++) {
                     if (colliders [i].gameObject != gameObject) {
                         return true;
                         Debug.Log ("it is Grounded");
                     }
                 }    
             }
         }
         return false;
     }
 }

Thanks for your help! @JedBeryll

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
1
Best Answer

Answer by doublemax · Oct 06, 2016 at 08:13 AM

 Collider2D[] colliders = Physics2D.OverlapCircleAll (PointEffector2D.position, groundRadius, whatIsGround);

"PointEffector2D.position" should probably be "point.position".

Comment
Add comment · Show 21 · 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 MrBackstabby · Oct 06, 2016 at 12:23 PM 0
Share

Thank you! I'll try that. What about the other errors? @doublemax

avatar image doublemax MrBackstabby · Oct 06, 2016 at 01:22 PM 0
Share

I believe all errors are caused by the same problem. The reason for the warning should be obvious...

avatar image MrBackstabby doublemax · Oct 06, 2016 at 11:47 PM 0
Share

It is, thank you!

Show more comments
avatar image doublemax MrBackstabby · Oct 07, 2016 at 12:06 AM 0
Share

Now I am having another issue where jump is permanently triggered, do you know what could cause that?

ResetValues() is never called and "jump" is never reset to false again.

avatar image MrBackstabby doublemax · Oct 07, 2016 at 12:13 AM 0
Share

This is a very beginner question but how do i call ResetValues()? I thought it would be called as is, what did I do wrong?

Show more comments
Show more comments
avatar image doublemax MrBackstabby · Oct 07, 2016 at 12:44 AM 0
Share

Try this:

 if (isGrounded && jump)
 {
   isGrounded = false;
   myRigidbody.AddForce (new Vector2 (0, jumpForce));
   ResetValues ();
 }

( Going offline soon, so no more answers from me in the next hours :) )

avatar image MrBackstabby doublemax · Oct 07, 2016 at 12:49 AM 0
Share

Now it won't jump at all, but at least it isn't stuck going up. Thank you for your help so far! Once you get back online, do you know what the problem is?

Show more comments
Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

moving player top down,movement in unity 2d 0 Answers

How to make a sprite respond to a specific color? 0 Answers

When 2D Car Turns Upside Down, Game Over Scene Should appear. 1 Answer

Stuttering in simple 2D game using interpolation? 1 Answer

Why Is there A slight jitteryness on player movement and camera? 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