public void Test() { // Create some input actions to move around the ground with var inputActions = new List <InputAction> { new InputAction("Left", Buttons.LeftThumbstickLeft, Keys.A), new InputAction("Right", Buttons.LeftThumbstickLeft, Keys.D), new InputAction("Forward", Buttons.LeftThumbstickLeft, Keys.W), new InputAction("Backward", Buttons.LeftThumbstickLeft, Keys.S), }; // Add these input actions to our Input Handler InputHandler.Commands.AddRange(inputActions); Camera = new FPSCamera(this); Camera.Position = new Vector3(-1000, 200, 1000); Camera.FarPlane = 12000f; Components.Add(Camera); Stadium = new Model(this, "Stadium1", Camera); Components.Add(Stadium); Run(); }
public void Die() { transform.position = respawnPoint.transform.position; m_Player = FindObjectOfType <Player>(); m_Bending = FindObjectOfType <Bending>(); m_Crouching = FindObjectOfType <Crouching>(); m_FPSCamera = FindObjectOfType <FPSCamera>(); m_Interaction = FindObjectOfType <Interaction>(); m_Animator = GetComponentInChildren <Animator>(); //m_Animator.Play("Death"); canvas.SetActive(false); deathCanvas.SetActive(true); m_Player.enabled = false; m_Bending.enabled = false; m_Crouching.enabled = false; m_FPSCamera.enabled = false; m_Interaction.enabled = false; Invoke("Revive", deathTime); }
void Update() { if (!fpscamera) { VRSetup = false; } // Ugly, but works for now, assumes player is always created in elevator if (!VRSetup && FocusStateManager.CurrentState.Equals(eFocusState.InElevator)) { if (!fpscamera) { Debug.LogWarning("Performing performance heavy lookup for fpscamera..."); fpscamera = FindObjectOfType <FPSCamera>(); } if (!playerController) { Debug.LogWarning("Performing performance heavy lookup for playerController..."); playerController = FindObjectOfType <PlayerCharacterController>(); } if (fpscamera && playerController && !VRSetup) { Setup(); } } else { UpdateOrigin(); } }
private static void Prefix(FPSCamera __instance) { Vector3 euler = HMD.GetVRCameraEulerRelativeToFPSCameraParent(); __instance.m_pitch = euler.x; __instance.m_yaw = euler.y; }
void Awake() { character = this.GetComponent<CharacterSystem>(); GameObject fpscam = this.transform.FindChild ("FPScamera").gameObject; if (fpscam) FPScamera = fpscam.GetComponent<FPSCamera> (); }
public void InitializeSettings() { camera = Camera.main.GetComponent <FPSCamera>(); yOffsetField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_LOCAL_Y_OFFSET); int useSmoothLook = PlayerPrefs.GetInt(CameraSettings.Instance.FPS_USE_SMOOTH_LOOK); if (useSmoothLook == 0) { useSmoothLookField.isOn = false; } else { useSmoothLookField.isOn = true; } smoothLookTimeField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_SMOOTH_LOOK_TIME); xSensitivityField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_X_LOOK_SENSITIVITY); ySensitivityField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_Y_LOOK_SENSITIVITY); int useBounce = PlayerPrefs.GetInt(CameraSettings.Instance.FPS_USE_BOUNCE); if (useBounce == 0) { useBounceField.isOn = false; } else { useBounceField.isOn = true; } bounceFrequencyField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_BOUNCE_FREQUENCY); bounceAmplitudeField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_BOUNCE_AMPLITUDE); }
protected void Start() { if (SpeedText == null) { Debug.LogWarning("SpeedText object is null"); return; } if (EngineRPMText == null) { Debug.LogWarning("EngineRPMText object is null"); return; } var camera = GameObject.Find("Main Camera"); Assert.IsNotNull(camera); SpeedText.text = string.Format("Speed {0:0.00} Km/h", Speed * 3.6); EngineRPMText.text = string.Format("Engine: {0:0000} rpm", EngineRPM); FPSCameraScript = camera.GetComponent <FPSCamera>(); Assert.IsNotNull(FPSCameraScript, "Missing FPS Camera Object"); CameraFollowScript = camera.GetComponent <CameraFollow>(); Assert.IsNotNull(CameraFollowScript, "Missing Camera Follow Object"); Assert.IsNotNull(GroundTireMaterial, "ContactMaterial Tire Ground is missing"); FrictionSlider.value = GroundTireMaterial.FrictionCoefficients[0]; }
private static bool Prefix(FPSCamera __instance) { bool vis = false; if (VRConfig.configUseControllers.Value) { //Used for throwing weapons __instance.CameraRayDir = HMD.GetVRInteractionLookDir(); RaycastHit hit; if (Physics.Raycast(Controllers.GetAimFromPos(), Controllers.GetAimForward(), out hit, 50f, LayerManager.MASK_CAMERA_RAY)) { __instance.CameraRayPos = hit.point; __instance.CameraRayCollider = hit.collider; __instance.CameraRayNormal = hit.normal; __instance.CameraRayObject = hit.collider.gameObject; __instance.CameraRayDist = hit.distance; if (FPSCamera.FriendlyTargetVisAllowed && hit.collider.gameObject.layer == LayerManager.LAYER_PLAYER_SYNCED) { vis = true; } } else { __instance.CameraRayPos = Controllers.GetAimFromPos() + Controllers.GetAimForward() * 50f; __instance.CameraRayCollider = null; __instance.CameraRayNormal = -Controllers.GetAimForward(); __instance.CameraRayObject = null; __instance.CameraRayDist = 0.0f; } } GuiManager.CrosshairLayer.SetFriendlyTargetVisible(vis); return(false); }
public override void Interaction() { m_Player = FindObjectOfType <Player>(); m_Bending = FindObjectOfType <Bending>(); m_Crouching = FindObjectOfType <Crouching>(); m_FPSCamera = FindObjectOfType <FPSCamera>(); m_Interaction = FindObjectOfType <Interaction>(); m_Player.enabled = false; m_Bending.enabled = false; m_Crouching.enabled = false; m_FPSCamera.enabled = false; m_Interaction.enabled = false; m_AudioSource.Play(); letter.SetActive(true); meshRenderer.enabled = false; if (!alreadyActivated) { for (int i = 0; i < objectToActivateBefore.Length; i++) { objectToActivateBefore[i].Interaction(); } } }
public void Generate() { // Create our camera Camera = new FPSCamera(this); Camera.Position = new Vector3(128, 10, 128); Components.Add(Camera); // Create our Plane Primitive groundPlane = new Plane(this, 256, 256, Camera); groundPlane.FillMode = FillMode.Solid; Components.Add(groundPlane); // Create some input actions to move around the ground with var inputActions = new List <InputAction> { new InputAction("Left", Buttons.LeftThumbstickLeft, Keys.A), new InputAction("Right", Buttons.LeftThumbstickLeft, Keys.D), new InputAction("Forward", Buttons.LeftThumbstickLeft, Keys.W), new InputAction("Backward", Buttons.LeftThumbstickLeft, Keys.S), }; // Add these input actions to our Input Handler InputHandler.Commands.AddRange(inputActions); Run(); }
private void Awake() { cam = this; cam_ = this.GetComponent <Camera>(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; }
private void SetCamera() { // Cambio el farPlane D3DDevice.Instance.Device.Transform.Projection = TGCMatrix.PerspectiveFovLH(D3DDevice.Instance.FieldOfView, D3DDevice.Instance.AspectRatio, D3DDevice.Instance.ZNearPlaneDistance, D3DDevice.Instance.ZFarPlaneDistance * 10f).ToMatrix(); Camera = new FPSCamera(this, Player, Player.RelativeEyePosition); }
void Start() { hasScanned = false; camscript = fpscam.GetComponent <FPSCamera>(); laser = Instantiate(laserPrefab); toggle = eventsystem.GetComponent <Toggle>(); // 2 laserTransform = laser.transform; }
private void Start() { if (player != null) { m_ScriptPlayer = player.GetComponent <Player>(); m_ScriptCamera = player.GetComponentInChildren <FPSCamera>(); m_ScriptInteraction = player.GetComponentInChildren <Interaction>(); } }
public void Init() { Profiler.maxNumberOfSamplesPerFrame = -1; standard = Camera.main.GetComponent<StandardCamera>(); topDown = Camera.main.GetComponent<TopDownCamera>(); rts = Camera.main.GetComponent<RTSCamera>(); fps = Camera.main.GetComponent<FPSCamera>(); SwitchToCamera(PlayerPrefs.GetInt(CameraSettings.Instance.CAMERA_TYPE)); }
public void Init() { Profiler.maxNumberOfSamplesPerFrame = -1; standard = Camera.main.GetComponent <StandardCamera>(); topDown = Camera.main.GetComponent <TopDownCamera>(); rts = Camera.main.GetComponent <RTSCamera>(); fps = Camera.main.GetComponent <FPSCamera>(); SwitchToCamera(PlayerPrefs.GetInt(CameraSettings.Instance.CAMERA_TYPE)); }
void Start() { animator = this.GetComponent <Animator>(); character = this.GetComponent <CharacterSystem>(); if (headCamera == null) { FPSCamera fpscam = this.GetComponentInChildren <FPSCamera>(); headCamera = fpscam.gameObject.transform; } }
public static void UpdateVRCameraTransform(FPSCamera fpsCamera) { if (!FocusStateManager.CurrentState.Equals(eFocusState.InElevator)) { fpsCamera.transform.position = HMD.GetWorldPosition(); } fpsCamera.m_camera.transform.parent.localRotation = Quaternion.Euler(HMD.GetVRCameraEulerRelativeToFPSCameraParent()); fpsCamera.UpdateCameraRay(); }
protected override void Initialize() { GL.ClearColor(.25f, .30f, .35f, 1f); Mouse.ShouldCenterMouse = true; Mouse.CursorVisible = false; GL.CullFace(CullFaceMode.Back); GL.Enable(EnableCap.CullFace); testTexture = Content.Load <Texture2D> ("testWoodDiffuse.jpg", TextureConfiguration.Linear); var normal = Content.Load <Texture2D> ("testWoodNormal.jpg", TextureConfiguration.Linear); var res = new Resolution { Width = Configuration.Width, Height = Configuration.Height }; camera = new FPSCamera(60f, res, Mouse, Keyboard); camera.Camera.SetAbsolutePosition(new Vector3(0, 0, 2)); camera.MouseRotation.X = MathHelper.DegreesToRadians(180); var obj = Content.LoadMultiple <Geometry> ("plane.obj"); var rand = new Random(); foreach (Geometry geom in obj) { //geom.Material = new Material (new Color4((byte) rand.Next(0, 255), (byte) rand.Next (0, 255), (byte) rand.Next (0, 255), 255), testTexture, normal, 32, 16); geom.Material = new Material(Color4.White, null, null, 32, 16); models.Add(new Model(geom)); } /*this.RenderingPipeline.AddDirectionalLight (new DirectionalLight { * @base = new BaseLight { * Color = new Vector3 (1f), * Intensity = 1f, * }, * direction = new Vector3 (0, 1, -1) * });*/ Func <Random, float, float, float> randPos = (rnd, min, max) => min + (float)rnd.NextDouble() * (max - min); for (int i = 0; i < 64; i++) { this.RenderingPipeline.AddPointLight(new PointLight { @base = new BaseLight { Color = new Vector3((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble()), Intensity = .25f }, atten = new Attenuation { constant = 2f, exponent = .5f, linear = 1f, }, position = new Vector3(randPos(rand, -5, 5), randPos(rand, .125f, .75f), randPos(rand, -5, 5)), }); } base.Initialize(); }
static void Postfix(FPSCamera __instance, PlayerAgent ___m_owner) { if (!PlayerVR.VRSetup) { return; } if (VRSettings.VR_TRACKING_TYPE.Equals(TrackingType.PositionAndRotation) && !FocusStateManager.CurrentState.Equals(eFocusState.InElevator)) { __instance.Position = ___m_owner.PlayerCharacterController.SmoothPosition + HMD.GetPosition(); } }
protected override void Initialize() { GameUtilities.Content = Content; GameUtilities.GraphicsDevice = GraphicsDevice; _debug.Initialize(); MainCamera = new FPSCamera(this, new Vector3(0, 100, 200), Vector3.Zero, 40f, 10f); base.Initialize(); }
static void Postfix(FPSCamera __instance) { if (!PlayerVR.VRSetup) { return; } Vector3 euler = __instance.m_camera.transform.parent.localEulerAngles; euler.z = HMD.GetVRCameraEulerRotation().z; __instance.m_camera.transform.parent.localRotation = Quaternion.Euler(euler); }
public ExampleScene(GameWindow window) : base(typeof(PointCloud)) { this.Cameras.Add(camera = new FPSCamera() { Velocity = 3 }); this.Components.Add(pointCloud = new PointCloud()); camera.Initialize(window); }
private void AppendVRComponents() { if (m_currentFPSCameraRef == null || m_currentPlayerAgentRef == null) { Log.Warning("Tried to spawn player but FPS camera or playeragent ref was null, this should never happen! Falling back to FindObjectOfType"); m_currentFPSCameraRef = FindObjectOfType <FPSCamera>(); m_currentPlayerAgentRef = m_currentFPSCameraRef.m_owner; } m_player = m_currentFPSCameraRef.gameObject.AddComponent <VRPlayer>(); m_player.Setup(m_currentFPSCameraRef, m_currentPlayerAgentRef); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { camera = new FPSCamera(GraphicsDevice.Viewport); FPS_Counter_On = config.SettingGroups["DebugFeatures"].Settings["FPSCounterOn"].GetValueAsBool(); // Comment this to remove the framerate counter if (FPS_Counter_On == true) { Components.Add(new FrameRateCounter(this)); } base.Initialize(); }
void Start() { targetRotation = transform.rotation; if (GetComponent<Rigidbody>()) rBody = GetComponent<Rigidbody>(); else Debug.LogError("The character needs a rigidbody."); forwardInput = turnInput = jumpInput = 0; standardCam = Camera.main.GetComponent<StandardCamera>(); fpsCam = Camera.main.GetComponent<FPSCamera>(); fpsCam.enabled = false; }
private static void Postfix(FPSCamera __instance) { if (!FocusStateManager.CurrentState.Equals(eFocusState.InElevator)) { __instance.Position = HMD.GetWorldPosition(); } Vector3 euler = __instance.m_camera.transform.parent.localEulerAngles; euler.z = HMD.GetVRCameraEulerRelativeToFPSCameraParent().z; __instance.m_camera.transform.parent.localRotation = Quaternion.Euler(euler); __instance.UpdateFlatTransform(); }
private static void Postfix(FPSCamera __instance) { // Repeat position inject or the transforms will get out of sync (Unity transform handling mumbo jumbo ensues, frame later or frame behind tracking) if (!FocusStateManager.CurrentState.Equals(eFocusState.InElevator)) { __instance.Position = HMD.GetWorldPosition(); } Vector3 euler = HMD.GetVRCameraEulerRelativeToFPSCameraParent(); __instance.m_pitch = euler.x; __instance.m_yaw = euler.y; }
private static void Postfix(FPSCamera __instance, ref Vector3 __result) { if (!VRConfig.configUseControllers.Value) { return; } if (useInteractionControllersPosition) { __result = HMD.GetVRInteractionFromPosition(); } if (useControllerPosition) { __result = Controllers.GetAimForward(); } }
public void Setup(FPSCamera camera, PlayerAgent agent) { FpsCamera = camera; PlayerAgent = agent; m_origin = new GameObject("Origin").AddComponent <PlayerOrigin>(); m_origin.Setup(PlayerAgent); m_snapTurn = gameObject.AddComponent <Snapturn>(); m_snapTurn.Setup(m_origin); gameObject.AddComponent <VRWorldSpaceUI>(); m_movementVignette = gameObject.AddComponent <MovementVignette>(); m_movementVignette.Setup(agent.Locomotion, GetComponent <PostProcessingBehaviour>()); m_weaponRadial = gameObject.AddComponent <WeaponRadialMenu>(); m_weaponRadial.Setup(m_origin.transform); m_weaponAmmoHolo = gameObject.AddComponent <WeaponAmmoHologram>(); m_weaponAmmoHolo.Setup(); GameObject laserPointer = new GameObject("LaserPointer"); m_pointer = laserPointer.AddComponent <LaserPointer>(); m_fade = FpsCamera.gameObject.AddComponent <CollisionFade>(); m_fade.Setup(PlayerAgent); FpsCamera.gameObject.AddComponent <SteamVR_Camera>(); FpsCamera.gameObject.AddComponent <VRRendering>(); FpsCamera.gameObject.AddComponent <SteamVR_Fade>(); m_watch = Instantiate(VRAssets.GetWatchPrefab(), Vector3.zero, Quaternion.identity, null).AddComponent <Watch>(); m_watch.Setup(m_origin.transform); m_haptics = gameObject.AddComponent <Haptics>(); m_haptics.Setup(); m_bhapticsIntegration = gameObject.AddComponent <BhapticsIntegration>(); m_bhapticsIntegration.Setup(agent); PlayerLocomotionEvents.OnPlayerEnterLadder += PlayerEnteredLadder; SteamVR_Events.NewPosesApplied.Listen(new Action(OnNewPoses)); VRConfig.configLightResMode.SettingChanged += LightResChanged; RefreshClusteredRenderingResolution(); }
/// <summary> /// Move camera according to rotation angle and zoom factor /// </summary> private void UpdateCamera() { this.aspectRatio = (float)this.GraphicsDevice.PresentationParameters.BackBufferWidth / this.GraphicsDevice.PresentationParameters.BackBufferHeight; camera = new FPSCamera(this.aspectRatio, this.lookAt) { Position = this.posCamera, Zoom = this.zoomCamera, Pitch = this.pitchCamera, Yaw = this.yawCamera }; this.viewMatrix = camera.getViewMatrix; this.projectionMatrix = camera.getProjectionMatrix; }
public void Update() { if (Input.GetKeyDown(KeyCode.F1)) { if (!FreecamEnabled) { FPSCameraHolder fpsCamHolder = GameObject.FindObjectOfType <FPSCameraHolder>(); FPSCamera fpsCamera = GameObject.FindObjectOfType <FPSCamera>(); //fpsCamera.gameObject.transform.GetChild(1)?.gameObject.SetActive(false); //UI_Apply ui = GameObject.FindObjectOfType<UI_Apply>(); //ui.enabled = false; //fpsCamHolder.m_flatTrans.gameObject.SetActive(false); player = fpsCamHolder.m_owner.gameObject; PlayerLocomotion = player.GetComponent <PlayerLocomotion>(); PlayerLocomotion.enabled = false; //Global.EnemyPlayerDetectionEnabled = false; } else { //FPSCameraHolder fpsCam = GameObject.FindObjectOfType<FPSCameraHolder>(); //fpsCam.m_flatTrans.gameObject.SetActive(true); // //FPSCamera fpsCamera = GameObject.FindObjectOfType<FPSCamera>(); //fpsCamera.gameObject.transform.GetChild(1)?.gameObject.SetActive(true); PlayerLocomotion.enabled = true; //Global.EnemyPlayerDetectionEnabled = true; //UI_Apply ui = GameObject.FindObjectOfType<UI_Apply>(); //ui.enabled = true; } FreecamEnabled = !FreecamEnabled; FreecamMain.log.LogMessage(FreecamEnabled == true ? "Freecam Enabled" : "Freecam Disabled"); } if (FreecamEnabled) { UpdateMovement(); PlayerLocomotion.m_owner.m_movingCuller.UpdatePosition(player.transform.position); PlayerLocomotion.m_owner.Sync.SendLocomotion(PlayerLocomotion.m_currentStateEnum, player.transform.position, PlayerLocomotion.m_owner.FPSCamera.Forward, 0, 0); } }
/// <summary> /// Modo: CameraMode /// </summary> private void radioButtonCameraMode_CheckedChanged(object sender, EventArgs e) { if (radioButtonCameraMode.Checked) { unselectAllModes(radioButtonCameraMode); currentState = GuiState.CameraMode; FPSCamera.SetCamera(BasicCamera.Position, BasicCamera.LookAt); editor.Camera = FPSCamera; cameraSpeed.Enabled = true; } else { BasicCamera.SetCamera(FPSCamera.Position, FPSCamera.LookAt); editor.Camera = BasicCamera; cameraSpeed.Enabled = false; } }
public void InitializeSettings() { camera = Camera.main.GetComponent<FPSCamera>(); yOffsetField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_LOCAL_Y_OFFSET); int useSmoothLook = PlayerPrefs.GetInt(CameraSettings.Instance.FPS_USE_SMOOTH_LOOK); if (useSmoothLook == 0) useSmoothLookField.isOn = false; else { useSmoothLookField.isOn = true; } smoothLookTimeField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_SMOOTH_LOOK_TIME); xSensitivityField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_X_LOOK_SENSITIVITY); ySensitivityField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_Y_LOOK_SENSITIVITY); int useBounce = PlayerPrefs.GetInt(CameraSettings.Instance.FPS_USE_BOUNCE); if (useBounce == 0) useBounceField.isOn = false; else { useBounceField.isOn = true; } bounceFrequencyField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_BOUNCE_FREQUENCY); bounceAmplitudeField.value = PlayerPrefs.GetFloat(CameraSettings.Instance.FPS_BOUNCE_AMPLITUDE); }
protected override void Initialize () { this._aspectRatio = Simulation3D.Form.pictureBoxSurface.Width / Simulation3D.Form.pictureBoxSurface.Height; camera = new FPSCamera ( this._aspectRatio, this._lookAt ); base.Initialize (); }
/// <summary> /// Move Camera according to rotation angle and zoom factor. /// </summary> private void UpdateCamera() { this._aspectRatio = (float) this.GraphicsDevice.PresentationParameters.BackBufferWidth / this.GraphicsDevice.PresentationParameters.BackBufferHeight; camera = new FPSCamera ( this._aspectRatio, this._lookAt ); camera.Position = this._posCamera; camera.Zoom = this._zoomCamera; camera.Pitch = this._pitchCamera; camera.Yaw = this._yawCamera; this._viewMatrix = camera.getViewMatrix; this._projectionMatrix = camera.getProjectionMatrix; }