Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created November 19, 2018 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/a2bf0829bbb3e5cb7c9c240ff6e1c002 to your computer and use it in GitHub Desktop.
Save tsubaki/a2bf0829bbb3e5cb7c9c240ff6e1c002 to your computer and use it in GitHub Desktop.
MultiPhysicsSceneのテスト用(2)
using UnityEngine;
using UnityEngine.SceneManagement;
public class CreateScene : MonoBehaviour
{
[SerializeField] string sceneName = "SubScene";
[SerializeField] Collider groundCollider;
[SerializeField] GameObject moveGameObject;
private PhysicsScene physicsScene;
[SerializeField]
[Range(0.1f, 5)]
float speed = 1;
void Start()
{
Scene scene = SceneManager.CreateScene(sceneName, new CreateSceneParameters(LocalPhysicsMode.Physics3D));
physicsScene = scene.GetPhysicsScene();
// 地面を移植して、指定したGameObjectを指定シーンへ移動させる
SceneManager.MoveGameObjectToScene(Instantiate(groundCollider.gameObject), scene);
SceneManager.MoveGameObjectToScene(moveGameObject, scene);
}
private void FixedUpdate()
{
physicsScene.Simulate(Time.fixedDeltaTime * speed);
}
}
@tsubaki
Copy link
Author

tsubaki commented Nov 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment