public static void OnBeginPlay() { Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!"); World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera")); World.SetOnActorBeginOverlapCallback(OnActorBeginOverlap); World.SetOnActorEndOverlapCallback(OnActorEndOverlap); World.SetOnActorHitCallback(OnActorHit); World.SetOnComponentBeginOverlapCallback(OnComponentBeginOverlap); World.SetOnComponentEndOverlapCallback(OnComponentEndOverlap); World.SetOnComponentHitCallback(OnComponentHit); const float linesThickness = 3.0f; TriggerBox triggerBox = new TriggerBox(); BoxComponent collisionComponent = triggerBox.GetComponent <BoxComponent>(); Vector3 collisionLocation = new Vector3(0.0f, 0.0f, 0.0f); Vector3 collisionShape = new Vector3(200.0f, 200.0f, 200.0f); collisionComponent.GetLocation(ref collisionLocation); collisionComponent.SetBoxExtent(collisionShape); Debug.DrawBox(collisionLocation, collisionShape, Quaternion.Identity, Color.Aqua, true, thickness: linesThickness); leftActor.RegisterEvent(ActorEventType.OnActorBeginOverlap); leftActor.RegisterEvent(ActorEventType.OnActorEndOverlap); leftActor.RegisterEvent(ActorEventType.OnActorHit); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentBeginOverlap); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentEndOverlap); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentHit); leftStaticMeshComponent.SetGenerateOverlapEvents(true); leftStaticMeshComponent.SetGenerateHitEvents(true); leftStaticMeshComponent.SetStaticMesh(StaticMesh.Cube); leftStaticMeshComponent.SetMaterial(0, material); leftStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.Green); leftStaticMeshComponent.SetWorldLocation(new Vector3(0.0f, -startY, 0.0f)); leftStaticMeshComponent.SetEnableGravity(false); leftStaticMeshComponent.SetSimulatePhysics(true); rightActor.RegisterEvent(ActorEventType.OnActorBeginOverlap); rightActor.RegisterEvent(ActorEventType.OnActorEndOverlap); rightActor.RegisterEvent(ActorEventType.OnActorHit); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentBeginOverlap); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentEndOverlap); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentHit); rightStaticMeshComponent.SetGenerateOverlapEvents(true); rightStaticMeshComponent.SetGenerateHitEvents(true); rightStaticMeshComponent.SetStaticMesh(StaticMesh.Cube); rightStaticMeshComponent.SetMaterial(0, material); rightStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.Yellow); rightStaticMeshComponent.SetWorldLocation(new Vector3(0.0f, startY, 0.0f)); rightStaticMeshComponent.SetEnableGravity(false); rightStaticMeshComponent.SetSimulatePhysics(true); }
public void OnBeginPlay() { playerController.ShowMouseCursor = true; playerController.EnableClickEvents = true; playerController.EnableMouseOverEvents = true; playerController.SetViewTarget(World.GetActor <Camera>("MainCamera")); World.SetOnActorBeginOverlapCallback(OnActorBeginOverlap); World.SetOnActorEndOverlapCallback(OnActorEndOverlap); World.SetOnActorHitCallback(OnActorHit); World.SetOnActorBeginCursorOverCallback(OnActorBeginCursorOver); World.SetOnActorEndCursorOverCallback(OnActorEndCursorOver); World.SetOnActorClickedCallback(OnActorClicked); World.SetOnActorReleasedCallback(OnActorReleased); World.SetOnComponentBeginOverlapCallback(OnComponentBeginOverlap); World.SetOnComponentEndOverlapCallback(OnComponentEndOverlap); World.SetOnComponentHitCallback(OnComponentHit); World.SetOnComponentBeginCursorOverCallback(OnComponentBeginCursorOver); World.SetOnComponentEndCursorOverCallback(OnComponentEndCursorOver); World.SetOnComponentClickedCallback(OnComponentClicked); World.SetOnComponentReleasedCallback(OnComponentReleased); const float linesThickness = 3.0f; Vector3 collisionShape = new(200.0f, 200.0f, 200.0f); triggerCollisionComponent.SetBoxExtent(collisionShape); Debug.DrawBox(triggerCollisionComponent.GetLocation(), collisionShape, Quaternion.Identity, Color.Aqua, true, thickness: linesThickness); leftActor.RegisterEvent(ActorEventType.OnActorBeginOverlap); leftActor.RegisterEvent(ActorEventType.OnActorEndOverlap); leftActor.RegisterEvent(ActorEventType.OnActorHit); leftActor.RegisterEvent(ActorEventType.OnActorBeginCursorOver); leftActor.RegisterEvent(ActorEventType.OnActorEndCursorOver); leftActor.RegisterEvent(ActorEventType.OnActorClicked); leftActor.RegisterEvent(ActorEventType.OnActorReleased); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentBeginOverlap); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentEndOverlap); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentHit); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentBeginCursorOver); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentEndCursorOver); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentClicked); leftStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentReleased); leftStaticMeshComponent.SetGenerateOverlapEvents(true); leftStaticMeshComponent.SetGenerateHitEvents(true); leftStaticMeshComponent.SetStaticMesh(StaticMesh.Cube); leftStaticMeshComponent.SetMaterial(0, material); leftStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.Green); leftStaticMeshComponent.SetWorldLocation(new(0.0f, -startY, 0.0f)); leftStaticMeshComponent.UpdateToWorld(TeleportType.ResetPhysics); leftStaticMeshComponent.SetEnableGravity(false); leftStaticMeshComponent.SetSimulatePhysics(true); Assert.IsNotNull(leftStaticMeshComponent.GetMaterial(0)); rightActor.RegisterEvent(ActorEventType.OnActorBeginOverlap); rightActor.RegisterEvent(ActorEventType.OnActorEndOverlap); rightActor.RegisterEvent(ActorEventType.OnActorHit); rightActor.RegisterEvent(ActorEventType.OnActorBeginCursorOver); rightActor.RegisterEvent(ActorEventType.OnActorEndCursorOver); rightActor.RegisterEvent(ActorEventType.OnActorClicked); rightActor.RegisterEvent(ActorEventType.OnActorReleased); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentBeginOverlap); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentEndOverlap); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentHit); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentBeginCursorOver); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentEndCursorOver); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentClicked); rightStaticMeshComponent.RegisterEvent(ComponentEventType.OnComponentReleased); rightStaticMeshComponent.SetGenerateOverlapEvents(true); rightStaticMeshComponent.SetGenerateHitEvents(true); rightStaticMeshComponent.SetStaticMesh(StaticMesh.Cube); rightStaticMeshComponent.SetMaterial(0, material); rightStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.Yellow); rightStaticMeshComponent.SetWorldLocation(new(0.0f, startY, 0.0f)); rightStaticMeshComponent.UpdateToWorld(TeleportType.ResetPhysics); rightStaticMeshComponent.SetEnableGravity(false); rightStaticMeshComponent.SetSimulatePhysics(true); Assert.IsNotNull(rightStaticMeshComponent.GetMaterial(0)); }