Created
November 19, 2018 12:52
-
-
Save tsubaki/a2bf0829bbb3e5cb7c9c240ff6e1c002 to your computer and use it in GitHub Desktop.
MultiPhysicsSceneのテスト用(2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://tsubakit1.hateblo.jp/entry/2018/11/19/215036