- Home /
Question by
Immortal_troop · Mar 18, 2016 at 12:16 PM ·
childmovechange
when Player collide with pad become child of pad
I want the player to walk across moving pads. I want him to become a child of the pad so that when the pad moves the other way, the player doesn't fall off. I also want it so that when the key W is pressed the player is no longer a child of the pad. Can anyone help. this is what i have so far:
using UnityEngine; using System.Collections;
public class playerStay : MonoBehaviour {
public GameObject Pad;
public GameObject Player;
void OnHit(Transform Pad)
{
Quaternion randomRotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 360f));
Instantiate(Pad, transform.position, randomRotation);
GameObject go = Instantiate(Player, transform.position, transform.rotation) as GameObject;
go.transform.parent = Pad;
}
}
Comment
Your answer
Follow this Question
Related Questions
Change scripted gui text postion 0 Answers
Change material of all the children 2 Answers
Childs material 1 Answer
[Solved] Changing mesh of child gameobject 1 Answer
changing pivot's placement 2 Answers