- Home /
Possible Colliders problem. Maybe gravity problem.
hey.
I made a scene with player, 3Ds max mesh and some unity objects.
so I made simple "elevator" by using flat cube and "Trigger on stay" component and its working fine (the cube moving between edge of empty object which contain the script).
public GameObject nott;
private void OnTriggerStay() { movit.transform.position += movit.transform.up Time.deltaTime; nott.transform.position += nott.transform.up Time.deltaTime; }
then I made an automatic door with "Trigger in enter / exit" to the enter of the 3Ds max mesh (house) which is also working.
after that is wanted to give the elevator more realistic look and action and duplicated the automatic door and posit it to the enter of the lift floor and then the problems started to appear. as I press play, the player started to "fly" in the scene of falling down beneath the floor like there is no mesh collider or gravity in the scene.
but if I put the duplicate of the automatic door somewhere else in the scene, everything wirking fine again. someone know what cause this bug?
Good day.
Can we see the code with that collisiond etections (triggers) $$anonymous$$ost probably the colilders are activateing some method when you dont want to.
Also post some images of the scene to see the colliders, and the inspector of the elevator. (I recommend you to make a easy paint image with screenshots to post it here)
Ps: I changed a little the title to help you get an answer.
Bye!
Yes this is the elevator code:
public class elevator : $$anonymous$$onoBehaviour { public GameObject movit;
public GameObject nott;
private void OnTriggerStay()
{
movit.transform.position += movit.transform.up * Time.deltaTime;
nott.transform.position += nott.transform.up * Time.deltaTime;
}
}
this is the automatic door code:
public class Door : $$anonymous$$onoBehaviour { Animator animator; bool doorOpen; public AudioClip DoorSound;
// Start is called before the first frame update
void Start()
{
doorOpen = false;
animator = GetComponent<Animator>();
}
private void OnTriggerEnter(Collider col)
{
if(col.gameObject.tag == "Player")
{
gameObject.GetComponent<AudioSource>().PlayOneShot(DoorSound);
doorOpen = true;
DoorControl("Open");
}
}
private void OnTriggerExit(Collider col)
{
if (doorOpen)
{
gameObject.GetComponent<AudioSource>().PlayOneShot(DoorSound);
doorOpen = false;
DoorControl("Close");
}
}
void DoorControl (string direction)
{
animator.SetTrigger(direction);
}
}
now when I put the duplication of the door next to the elevator:
[url=https://postimages.org/][img]https://i.postimg.cc/B6sxSvvz/image.jpg[/img][/url]
my player starting to fly even if its in other place in the scene, outside the building and on another mesh:
[url=https://postimages.org/][img]https://i.postimg.cc/tgb1P$$anonymous$$HZ/e.jpg[/img][/url]
Please reformat this comment. You should also post the code on your question.
Answer by unity_DKqnJkGo8MOKYQ · Jan 28, 2019 at 06:01 PM
Could the player rigid body be "sleeping" perhaps? You could test w ProjectSettings / Physics / sleep threshold to 0, to see if that is it. If so, I would wake up player object everytime the elevator is activated.
there is no rigid body in the player. I think is something about the on trigger of the elevator with this of the door...some overlapping. But I don't know how to deal it