Hello everyone,
So i am currently working in a project were in if you press lmb the player will throw a projectile then after it hit the ground or wall the player wil teleport into that location.
Is there any way of making these possible?
Hello everyone,
So i am currently working in a project were in if you press lmb the player will throw a projectile then after it hit the ground or wall the player wil teleport into that location.
Is there any way of making these possible?
you could make a empty prefab (only a gameobject) and then instantiate it where the projectile hit. And then set the players position to the empty gameobjects position.
One way of doing it is to add a variable for the empty prefab.
Then add a script to THE PROJECTILE PREFAB. That has a collision checker
function OnCollisionEnter (collision : Collision)
{
if(collision.gameobject)
{
Instantiate (emptyGameObject, gameObject.transform.position, Quaternion.identity)
Destroy(gameObject, 0.1f);
//Or something like that, im not that good in collision.
}
}
Then maybe attach an other script to the empty gameobject that teleports the player to its position
var player : GameObject;
function Start ()
{
player = GameObject.Find(“Player”);
player.transform.position = gameObject.transform.position;
}
Something like that
Hope you’ll find a way