Hi, I am currently using a script for a moving platform to keep my player on it.
(My player is from the Dastardly Bannana)
the script is
function OnTriggerEnter (other : Collider) {
other.transform.parent = gameObject.transform;
}
function OnTriggerExit(other : Collider) {
other.transform.parent = null;
}
While this dose work to keep my player on a platform, All my weapons that are attached to my weapons cam will be displaced are become separated at each mesh.
All I need is a fast and easy fix to this problem.
Thank you.
(PS. Please don't just tell me to use the search function because I have and I have been looking for this for about two weeks now.)
(PSS. My platform moves both up, down, and side to side)
Thank you for your help.
Parent your weapons to your player (you probably did this already).
And you should tell your "OnTriggerEnter" and "Exit" functions to not affect the weapons - if these have colliders for themselves they will get attached to the platform, too. The easiest way to do this would maybe be to assign them to a different layer (e.g. Layer 8 = "PlayerWeapons")
Something like:
function OnTriggerEnter (other : Collider)
{
if(other.gameObject.layer != 8)
other.transform.parent = gameObject.transform;
}
Give the player gameobject a tag of "player"
var playerObject : GameObject;
function OnTriggerEnter (other : Collider) {
if(other.gameObject.tag == "player")
{
playerObject = other.gameObject;
}
}
function OnTriggerExit(other : Collider) {
if(other.gameObject.tag == "player")
{
playerObject = null;
}
}
then in your update for your plateform's position check on weather playerObject is null if not then update its position also.
if(playerObject != null)
{
//update player position
}