Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Instantiate to relative location?

$
0
0
#pragma strict var objectName : GameObject; //var player : GameObject; function Start() { } function Update() { if(Input.GetKeyDown(KeyCode.X)) { var pos = Vector2(15,1.5); var rot : Quaternion = Quaternion.identity; Instantiate(objectName,pos,rot); } } I'm creating a 2D infinite runner. This script will create a block at (15,1.5), but what I'd like to do is have this block appear at this location relative to the player,since they will always be running forward. I've been at this for awhile and just can't figure it out, since I'm pretty new to all of this. Any help is greatly appreciated!

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>