- Home /
 
               Question by 
               Clayyface · Apr 27, 2020 at 01:47 AM · 
                scripting problemscripting beginner  
              
 
              How to stop transform.Translate for 1 second?
Hey guys, so I'm trying to make a game (almost like 1 player pong) and id like it to pause for one second when it resets, any ideas? I've tried using coroutines like the script below, but I get the error: Argument 1: cannot convert from 'float' to 'UnityEngine.Vector3' Any help?
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using TMPro;
 
 public class BallScript : MonoBehaviour
 {
 
     float radius;
     Vector2 direction;
 
     public int score;
 
     public float speed;
 
     public TMP_Text scoreText;
 
     public bool shouldMove;
 
     // Start is called before the first frame update
     void Start()
     {
         direction = Vector2.one.normalized;
         radius = transform.localScale.x / 2;
         score = 0;
     }
 
     // Update is called once per frame
     void Update()
     {
         // zoom
         transform.Translate(direction * speed * Time.deltaTime);
 
         // text changer
         scoreText.text = score.ToString();
     }
     // player hit collider
     void OnTriggerEnter2D(Collider2D other)
     {
         // if hit is the player
         if (other.tag == "Player")
         {
             Debug.Log(other.transform.name);
             // grabbing isRight bool from paddle script
             if (Random.Range(0, 2) == 0)
             {
                 direction.x = -direction.x + .3f;
                 direction.y = -direction.y - .3f;
                 Debug.Log("0");
             }
             else
             {
                 direction.x = -direction.x - .3f;
                 direction.y = -direction.y - .3f;
                 Debug.Log("1");
             }
             score += 1;
         }
         else if (other.tag == "collidable")
         {
             score = 0;
             transform.position = new Vector2(0, 0);
             StartCoroutine(WaitCoroutine());
             transform.Translate(0 * 0 * Time.deltaTime);
             Debug.Log("Lost!");
         }
     }
 
     IEnumerator WaitCoroutine()
     {
         yield return new WaitForSeconds(1);
         transform.Translate(direction * speed * Time.deltaTime);
     }
 }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                