Search Unity

Unity Character Controller Move On A Moving Platform

Discussion in 'Scripting' started by joeyxiong1994, Aug 12, 2019.

  1. joeyxiong1994

    joeyxiong1994

    Joined:
    Apr 18, 2017
    Posts:
    20
    Hi I'm using a unity character controller to control my player. I have a moving platform which use script in Update function to move in a fixed velocity.

    I tried to attach my player object to be one of child object of this moving platform when OnTriggerEnter, and separate them when OnTriggerExit. However, looks like it's still unable to let my character auto move along with the moving platform.

    Is character controller Move function move in localPosition possibly? Or how to deal with Moving Platform when using a character controller? Thanks
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    With moving platform, move your charater when platform moved. When grounded on platform, save position of platform. In the next frame check how many it moved and move your charater accordingly