Forum rules - please read before posting.

Rigidbody toggle kinetic of all players and npc's on switching 2D/3D scenes

edited October 2023 in Technical Q&A

Hi there,

We're creating a game featuring both 2D and 3D scenes (with a 2D look). Toggling the "is kinetic" boolean on the Players and NPC's makes them interact right with the 2d scenes and 3d terrains. But what would be a good way to do toggle this boolean on the start of a 2D/3D scene?

Should we add a custom script on every player/npc to check if the current scene is 2D or 3D?

Thanks a bunch :)

Daniel

Comments

  • edited October 2023

    Welcome to the community, @KAPOOOW.

    To distinguish between the two scene types, are you using the Scene Manager's Override the default camera perspective? option to set each scene's camera perspective?

    If so, you can check if the current scene is 2D with:

    AC.SceneSettings.IsUnity2D ()
    

    You can map this to an object's Is Kinematic option with:

    GetComponent<Rigidbody> ().isKinematic = AC.SceneSettings.IsUnity2D ();
    

    You should only need to affect the Rigidbody at runtime if a character can switch between scenes, however. If you place a Player character inside a scene file, they'll override the prefab you assign in the Settings Manager - so alternatively you could use separate Player characters for each scene, with the intended changes applied by default.

  • Hi Chris,

    Thank you so much for your swift reply and great solution. This is just what i needed.

    Cheers, Daniel
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.