Exemplo n.º 1
0
        public void OnBeginPlay()
        {
            World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera"));

            instancedStaticMeshComponent.SetStaticMesh(StaticMesh.Cube);
            instancedStaticMeshComponent.SetMaterial(0, material);
            instancedStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.White);

            for (int i = 0; i < maxCubes; i++)
            {
                sceneComponent.SetRelativeLocation(new(150.0f * i, 50.0f * i, 100.0f * i));
                sceneComponent.SetRelativeRotation(Maths.CreateFromYawPitchRoll(5.0f * i, 0.0f, 0.0f));
                sceneComponent.AddLocalOffset(new(15.0f * i, 20.0f * i, 25.0f * i));
                sceneComponent.GetTransform(ref transforms[i]);
                instancedStaticMeshComponent.AddInstance(transforms[i]);
            }

            Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Instances are created! Number of instances: " + instancedStaticMeshComponent.InstanceCount);
        }
Exemplo n.º 2
0
        public static void OnBeginPlay()
        {
            Debug.Log(LogLevel.Display, "Hello, Unreal Engine!");
            Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!");

            World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera"));

            instancedStaticMeshComponent.SetStaticMesh(StaticMesh.Cube);
            instancedStaticMeshComponent.SetMaterial(0, material);
            instancedStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.White);

            for (int i = 0; i < maxCubes; i++)
            {
                sceneComponent[i] = new SceneComponent(actor);
                sceneComponent[i].SetRelativeLocation(new Vector3(50.0f * i, 100.0f * i, 150.0f * i));
                sceneComponent[i].SetRelativeRotation(Quaternion.CreateFromYawPitchRoll(5.0f * i, 0.0f, 0.0f));
                sceneComponent[i].AddLocalOffset(new Vector3(15.0f * i, 20.0f * i, 25.0f * i));
                sceneComponent[i].GetTransform(ref transform);
                instancedStaticMeshComponent.AddInstance(transform);
            }

            Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Instances are created! Number of instances: " + instancedStaticMeshComponent.InstanceCount);
        }