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 Redmarketing · Jan 10, 2016 at 11:09 AM · 2d game2d-platformerendless runnerrunnerdead

Error pls help

@corns

Help I don't know what i did wrong. I got this error: Assets/scripts/player.cs(81,28): error CS1061: Type Gamemaneger' does not contain a definition for RestartGame' and no extension method RestartGame' of type Gamemaneger' could be found (are you missing a using directive or an assembly reference?) Scripts:

Player script:

using UnityEngine;

using System.Collections;

public class player : MonoBehaviour { public float moveSpeed; public float JumpForce;

 public float jumpTime;
 private float jumpTimeCounter;

 private Rigidbody2D myRigidbody;


 public bool grounded;
 public LayerMask whatisground;
 public Transform groundcheck;
 public float radius;

 private Collider2D mycollider;

 private Animator myanimator;

 public Gamemaneger theGamemanager;

 // Use this for initialization
 void Start () {
     myRigidbody = GetComponent<Rigidbody2D>();

     mycollider = GetComponent<Collider2D>();

     myanimator = GetComponent<Animator>();

     jumpTimeCounter = jumpTime;
 }
 
 // Update is called once per frame
 void Update () {

     //grounded = Physics2D.IsTouchingLayers(mycollider, whatisground);

     grounded = Physics2D.OverlapCircle(groundcheck.position, radius, whatisground);

     myRigidbody.velocity = new Vector2(moveSpeed, myRigidbody.velocity.y);

     if(Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
     {
         if(grounded)
         {
             myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, JumpForce);
         }
     }

     if (Input.GetKey (KeyCode.Space) || Input.GetMouseButton(0))
     {
         if(jumpTimeCounter > 0)
         {
             myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, JumpForce);
             jumpTimeCounter -= Time.deltaTime;
         }
     }

     if(Input.GetKeyUp (KeyCode.Space) || Input.GetMouseButtonUp(0))
     {
         jumpTimeCounter = 0;
     }

     if(grounded)
     {
         jumpTimeCounter = jumpTime;
     }
         

     myanimator.SetFloat("snelheid", myRigidbody.velocity.x);
     myanimator.SetBool("Grounded", grounded);
 } 

 void OnCollisionEnter2D (Collision2D other)
 {
     if(other.gameObject.tag == "killbox")
     {
         theGamemanager.RestartGame();
     }
 }

}

Gamemaneger script:

using UnityEngine; using System.Collections; using System;

public class Gamemaneger : MonoBehaviour {

 public Transform Platformgenerator;
 private Vector3 platformStartpoint;

 public player thePlayer;
 private Vector3 playerStartPoint;

 // Use this for initialization
 void Start () {
     platformStartpoint = Platformgenerator.position;
     playerStartPoint = thePlayer.transform.position;
 }
 
 // Update is called once per frame
 void Update ()
 { }

 public void RestartGame()
 {
     StartCoroutine(RestartGameCo());
 }

 public IEnumerator RestartGameCo()
 {
     thePlayer.gameObject.SetActive(false);
     yield return new WaitForSeconds(0.5f);
     thePlayer.transform.position = playerStartPoint;
     Platformgenerator.position = platformStartpoint;
     thePlayer.gameObject.SetActive(true);
 }

}

Comment
Add comment · Show 2
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 vintar · Jan 10, 2016 at 12:11 PM 0
Share

The error is on line 81 of Player.cs except you seem to have no line 81 in Player.cs so I guess you have other issues to fix first.

avatar image whalan84 vintar · Jan 10, 2016 at 03:12 PM 0
Share

I am guessing error is actually at line 74 within the code pasted.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by whalan84 · Jan 10, 2016 at 03:34 PM

Remembering I am only a beginner and I may be leading you astray here but as the Gamemaneger variable on line 16 is a public variable, try going to the unity inspector window for which ever object the 'player (script)' component is attached to and click the small circle next to 'Gamemaneger' and select an item which has the Gamemaneger script attached.

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

40 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

Related Questions

error: Assets/scripts/Gamemaneger.cs(27,51): error CS1525: Unexpected symbol `)' 1 Answer

Object pooling system. Objects aren't spawning 0 Answers

Help: Assets/scripts/Gamemaneger.cs(34,9): error CS0428: Cannot convert method group `FindObjectOfType' to non-delegate type `PlatformDeystoyer[]'. Consider using parentheses to invoke the method 1 Answer

How to check for colliders when teleporting the player in a 2D game? 0 Answers

transform.localScal not flipping 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