Question by
SenderZ · Jun 12, 2016 at 04:35 AM ·
c#distancetime.deltatime
Spawning 1 second away from a position
Hi, I was wondering how I would go about spawning a gameobject 1 second away from a target position. I was going to use: someGameObject.MoveTowards(someGameObject.position, target.position, Time.deltaTime); because (I think, anyway) it'll travel the distance within 1 second. However, I don't want to set a fixed distance because I don't want the gameObject to move too fast or too slow. Given an arbitrary screen size I want the speeds to be (generally) the same. So using Time.deltaTime I wanted to find a way to get a distance if it were to travel a straight line for 1 second.
Thanks :)
Comment
Are we talking 2D or 3D? Does your code not work? What exactly is going wrong? Why is the screen size a factor? In general you would want to do something like
someGameObject.transform.position = Vector3.$$anonymous$$oveTowards(someGameObject.transform.position,targetGameObject.transform.position,Time.deltaTime*speed);