void OnCollisionEnter2D(Collision2D col) { //Hook touches a object if (col.gameObject.tag == "HOOKSHOT" && !held) { transform.position = col.transform.position; //rb.simulated = false; col.gameObject.GetComponent <HookTip>().hookShot.CatchObject(gameObject); //Debug.Log("grabbed"); held = true; collectTimer = grabDelay; } //Grabbed object touches the home planet if (!isInstantBomb || !isOvertimeBomb) { if (col.gameObject.tag == "PLAYERPLANET" && col.gameObject != null && held) { _playerscore = col.gameObject.GetComponent <PlayerScore>(); _playerscore.AddingResource(value); gameObject.SetActive(false); held = false; } } }
void OrbitAroundPlanet() { if (!inOrbit) { orbitTimer = 0; } if (!held) { if (inOrbit) { transform.RotateAround(tempPlanet.transform.position, Vector3.forward, orbitSpeed * Time.deltaTime); //How to find the planet has to be reworked! but it rotates the astroid around the players planet //start a timer orbitTimer += Time.deltaTime; rb.velocity = new Vector2(0, 0); //float step = .1f * Time.deltaTime; // transform.position = Vector3.MoveTowards(transform.position, movePoint.position, step); if (!isOvertimeBomb) { if (orbitTimer >= orbitDuration) //if the astroid has finished his time in the orbit collect the points { _playerscore.AddingResource(value); gameObject.SetActive(false); inOrbit = false; held = false; //orbitTimer = 0; } } if (isOvertimeBomb) { //infectedAstroid.transform.position = rb.transform.position; if (orbitTimer >= orbitDuration) { _playerscore.AddingResource(value); orbitTimer = 0; } } //lerp resource slowly closer to the planet? Debug.Log("rotate around planet"); } } }