public static bool BuildingSphereCast(Vector3 a_pos) { Vector3 a_pos2 = a_pos; a_pos2.y = 2f; return(Raycaster.CheckSphere(a_pos2, 0.8f)); }
private void Update() { if (m_isDragging) { float newX = ((Raycaster.GetHitPoint() - transform.localPosition).x); if (newX < (Raycaster.GetHitPoint() - m_bottomClamp.localPosition).x) { newX = -0.01f; Vector3 newPosition1 = new Vector3(newX, 0, 0); transform.localPosition += newPosition1; OnDeselect(); return; } if (newX > (Raycaster.GetHitPoint() - m_topClamp.localPosition).x) { newX = 0.01f; Vector3 newPosition1 = new Vector3(newX, 0, 0); transform.localPosition += newPosition1; OnDeselect(); return; } Vector3 newPosition = new Vector3(newX, 0, 0); transform.localPosition += newPosition; } }
public void Update() { if (this._targetMode) { Raycaster.castRay(this.layerMask); if (Input.GetKeyDown(KeyCode.Escape)) { this._targetMode = false; CombatUiStateKeeper.displayAbilitySelectionStep(); this.abilityRangeSelection.hideRange(); CombatUiStateKeeper.jumpBackEnabled = true; } if (Input.GetKeyDown(KeyCode.Mouse0)) { GameObject target = GridController.getActiveTile().GetComponent <GridElement>().getCharacterOnThisTile(); CombatController.handleAbilityUsage(this._ability, target); this._targetMode = false; CombatUiStateKeeper.displayCommandStep(); this.baseCommandPanelHandler.disableAction(); this.abilityRangeSelection.hideRange(); } } }
void playerMovementController() { // get horizontal movement float xVelocity = Input.GetAxis("Horizontal"); if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D)) { movementAnimation.pressingMovementKey = true; if (Input.GetKey(KeyCode.A)) { rb.velocity = new Vector2(-moveSpeed, rb.velocity.y); } else { rb.velocity = new Vector2(moveSpeed, rb.velocity.y); } } else { movementAnimation.pressingMovementKey = false; rb.velocity = new Vector2(0, rb.velocity.y); } bool grounded = Raycaster.checkIfGrounded(transform.position); movementAnimation.grounded = grounded; // jump if the player is on the ground and presses the space bar if (Input.GetKeyDown(KeyCode.Space) && grounded) { rb.velocity = new Vector2(rb.velocity.x, jumpHeight); } }
private void Awake() { rb2d = GetComponent <Rigidbody2D>(); raycaster = GetComponent <Raycaster>(); bulletSpawnPoint = transform.Find("BulletSpawnPoint"); rocketSpawnPoint = transform.Find("RocketSpawnPoint"); }
public Vector3 GetPassengerExitPos(int a_id) { Vector3 result = Vector3.zero; Vector3 position = this.m_vehicle.transform.position; position.y = 0f; Vector3 vector = new Vector3(this.m_vehicle.transform.right.x, 0f, this.m_vehicle.transform.right.z); Vector3 normalized = vector.normalized; Vector3 vector2 = new Vector3(this.m_vehicle.transform.forward.x, 0f, this.m_vehicle.transform.forward.z); Vector3 normalized2 = vector2.normalized; for (int i = 0; i < 4; i++) { if (a_id == this.m_data.passengerIds[i]) { float num = (i % 2 != 0) ? 2.1f : -2.1f; float d = -num; float d2 = ((2 <= i) ? -1.5f : 0f) + UnityEngine.Random.Range(-0.5f, 0.5f); float num2 = 0.6f; Vector3 vector3 = position + normalized * num + normalized2 * d2; Vector3 vector4 = position + normalized * d + normalized2 * d2; vector3.y = (vector4.y = num2 + 0.2f); if (!Raycaster.CheckSphere(vector3, num2) && 0.8f < Util.GetTerrainHeight(vector3)) { result = vector3; } else if (!Raycaster.CheckSphere(vector4, num2) && 0.8f < Util.GetTerrainHeight(vector4)) { result = vector4; } break; } } return(result); }
// MonoBehaviour's INTERFACE void Awake() { for (int layerIndex = 0; layerIndex < m_Raycasters.Length; ++layerIndex) { m_Raycasters[layerIndex] = new Raycaster(layerIndex); } }
public void Initialize(IARModeUIController resolver) { m_ARModeUIController = (ARModeUIController)resolver; m_Raycaster = RaycasterRef.Resolve(m_ARModeUIController); DisposeSelectors(); m_FirstSelectedPlaneGetter = UISelectorFactory.createSelector <GameObject>(ARPlacementContext.current, nameof(IARPlacementDataProvider.firstSelectedPlane)); m_SecondSelectedPlaneGetter = UISelectorFactory.createSelector <GameObject>(ARPlacementContext.current, nameof(IARPlacementDataProvider.secondSelectedPlane)); m_PlacementRuleGameObjectGetter = UISelectorFactory.createSelector <GameObject>(ARPlacementContext.current, nameof(IARPlacementDataProvider.placementRulesGameObject)); m_ObjectSelectionInfoGetter = UISelectorFactory.createSelector <SelectObjectAction.IObjectSelectionInfo>(ProjectContext.current, nameof(IObjectSelectorDataProvider.objectSelectionInfo)); m_States = new Dictionary <ViewBasedInstructionUI, SetARInstructionUIAction.InstructionUIStep> { { ViewBasedInstructionUI.Init, new SetARInstructionUIAction.InstructionUIStep { stepIndex = (int)ViewBasedInstructionUI.Init, onNext = StartInstruction } }, { ViewBasedInstructionUI.AlignModelView, new SetARInstructionUIAction.InstructionUIStep { stepIndex = (int)ViewBasedInstructionUI.AlignModelView, onNext = AlignModelViewNext, onBack = AlignModelViewBack } }, { ViewBasedInstructionUI.FindTheFloor, new SetARInstructionUIAction.InstructionUIStep { stepIndex = (int)ViewBasedInstructionUI.FindTheFloor, onNext = FindTheFloorNext, onBack = FindTheFloorBack } }, { ViewBasedInstructionUI.ConfirmPlacement, new SetARInstructionUIAction.InstructionUIStep { stepIndex = (int)ViewBasedInstructionUI.ConfirmPlacement, onNext = ConfirmPlacementNext, onBack = ConfirmPlacementBack } }, { ViewBasedInstructionUI.OnBoardingComplete, new SetARInstructionUIAction.InstructionUIStep { stepIndex = (int)ViewBasedInstructionUI.OnBoardingComplete, onNext = OnBoardingCompleteNext } }, }; Dispatcher.Dispatch(SelectObjectAction.From(new ObjectSelectionInfo())); }
public void Update() { if (this._isMovementPhase) { Raycaster.castRay(1 << 9); if (Input.GetKeyDown(KeyCode.Escape)) { this._isMovementPhase = false; this._currentMovementRange.hideRange(); CombatUiStateKeeper.displayCommandStep(); } if (Input.GetKeyDown(KeyCode.Mouse0)) { GameObject clickedTile = GridController.getActiveTile(); GridElement gridElement = GridController.getActiveTile().GetComponent <GridElement>(); GameObject currentCharacterOnThisTile = GridController.getActiveTile().GetComponent <GridElement>().getCharacterOnThisTile(); if (this._currentMovementRange.isTileWithinRange(GridController.getActiveTile()) && currentCharacterOnThisTile == null && gridElement.tileType.passable == true) { this._isMovementPhase = false; TurnOrder.getActiveCharacter().GetComponent <CombatCharacterController>().setCharacterToTile(clickedTile); CombatUiStateKeeper.displayCommandStep(); this.baseCommandPanelHandler.disableMove(); this._currentMovementRange.hideRange(); Camera.main.GetComponent <CameraController>().setNextTargetTileForCamera(TurnOrder.getActiveCharacter().GetComponent <CombatCharacterController>().getCurrentTileOfCharacter()); } //play "wrong sound" } } }
public bool IsValidBuildPos(Vector3 a_pos, int a_buildingType) { foreach (DictionaryEntry building in m_buildings) { RemoteBuilding remoteBuilding = (RemoteBuilding)building.Value; if (null != remoteBuilding && !remoteBuilding.m_isStatic) { float sqrMagnitude = (remoteBuilding.transform.position - a_pos).sqrMagnitude; if ((!remoteBuilding.m_isMine && Buildings.IsDoor(remoteBuilding.m_type) && sqrMagnitude < 25f) || sqrMagnitude < 0.202499986f) { return(false); } } } if (!Buildings.IsHarmless(a_buildingType)) { SpecialArea[] specialAreas = m_specialAreas; foreach (SpecialArea specialArea in specialAreas) { if (null != specialArea && (specialArea.m_type == eAreaType.noBuilding || specialArea.m_type == eAreaType.noPvp) && (specialArea.transform.position - a_pos).sqrMagnitude < specialArea.m_radius * specialArea.m_radius) { return(false); } } } return(Buildings.IsDoor(a_buildingType) || !Raycaster.BuildingSphereCast(a_pos)); }
/// <summary> /// 点击角色部位检测 /// </summary> public void DoRaycast() { // Cast ray from pointer position. // var pos = Vector3.zero; //#if UNITY_EDITOR // pos = Input.mousePosition; //#else // pos = Input.touches[0].deltaPosition; //#endif var ray = Camera.main.ScreenPointToRay(Input.mousePosition); var hitCount = Raycaster.Raycast(ray, Results); // Return early if nothing was hit. if (hitCount == 0) { return; } if (_doRaycastNameList.Length <= 0) { return; } //Results[i].Drawable.name for (int i = 0; i < hitCount; i++) { HitLocation type = FindDrawableNamaInDoRaycastNameList(Results[i].Drawable.name); if (type != HitLocation.Loc_None) { _notifyPlayAnim?.Invoke(type); return; } } }
private float TraceShadowRay(Surfel surfel, Vector3 direction, float distance) { var position = surfel.point + surfel.normal * RenderConfig.bias; var isHit = Raycaster.Raycast(new Ray(position, direction), out var hit); return(isHit && hit.t < distance ? 0 : 1); }
/// <summary> /// Hit test. /// </summary> private void DoRaycast() { // Cast ray from pointer position. var ray = Camera.main.ScreenPointToRay(Input.mousePosition); var hitCount = Raycaster.Raycast(ray, Results); // Return early if nothing was hit. if (hitCount == 0) { ResultsText.text = "0"; return; } // Show results. ResultsText.text = hitCount + "\n"; for (var i = 0; i < hitCount; i++) { ResultsText.text += Results[i].Drawable.name + "\n"; Debug.Log(Results[i].Drawable.name + "\n"); } }
// Update is called once per frame void Update() { //This code below will change the color of the reticle if we are mousing over something if (RaycastHover2.getInstance().anythingHitByRay()) { GameObject objHitByRay = RaycastHover2.getInstance().getObjectHitByRay(); string objHitTag = objHitByRay.tag; // Check that there was a valid object hit by the raycast. Raycaster.getInstance().getObjectHitByRay() // returns null if no objects were hit by ray cast on this frame. Objects responding to input must have // one of the increment/decrement/slideshow tags set to be affected and cycled by raycast. if (objHitByRay != null) { if (objHitTag == "ChangeModel") { changeColor(1); } else if (objHitTag == "Respawn") { balloon[0].GetComponent <Renderer> ().material = newMat; } else { changeColor(0); balloon[0].GetComponent <Renderer> ().material = oldMat; } } else { changeColor(0); balloon[0].GetComponent <Renderer> ().material = oldMat; } } else { changeColor(0); balloon[0].GetComponent <Renderer> ().material = oldMat; } if (Raycaster.getInstance().anythingHitByRay()) { GameObject objHitByRay = Raycaster.getInstance().getObjectHitByRay(); string objHitTag = objHitByRay.tag; // Check that there was a valid object hit by the raycast. Raycaster.getInstance().getObjectHitByRay() // returns null if no objects were hit by ray cast on this frame. Objects responding to input must have // one of the increment/decrement/slideshow tags set to be affected and cycled by raycast. if (objHitByRay != null) { if (objHitTag == "ChangeModel") { SceneManager.LoadScene("VRBlockStack"); } if (objHitTag == "Respawn") { SceneManager.LoadScene("halfway"); } } } }
protected override void Start() { base.Start(); _rb = GetComponent <Rigidbody2D>(); _raycaster = GetComponent <Raycaster>(); IdleTimer = new Timer(20f); }
/// <summary> /// /// </summary> public override void Raycast(Raycaster raycaster, ref List <Intersect> intersects) { var matrixPosition = new Vector3(); matrixPosition.SetFromMatrixPosition(this.MatrixWorld); var distance = raycaster.Ray.Origin.DistanceTo(matrixPosition); this.GetObjectForDistance(distance).Raycast(raycaster, ref intersects); }
private Raycaster m_FrontRay; //移動方向レイ //初期化=================================================================== private void StartPhysics() { //接触 GROUND_MASK = 0x1 << LayerMask.NameToLayer(LayerNames.Ground); m_UnderRay = new Raycaster(); m_FrontDownRay = new Raycaster(); m_FrontRay = new Raycaster(); m_Gravity = new GravityStatus(); }
protected override void LeftSingleClick(Vector3 clickPosition) { RaycastHit2D hit = Raycaster.GetBoxCastHitByPosition(clickPosition, _rectanglePrefab.GetRectangleSize); if (!hit) { SpawnRectangle(clickPosition); } }
public static void CastAndDo(Vector3 from, Vector3 dir, float maxDistance, LayerMask mask, Action <RaycastHit> action) { if (!Instance) { var init = new GameObject("Job Raycaster"); Instance = init.AddComponent <Raycaster>(); } Instance.queue.Add(new RaySetup(from, dir, maxDistance, mask, action)); }
private void InitializeRaycaster() { var layermask = ~(1 << LayerMask.NameToLayer("Player") | 1 << LayerMask.NameToLayer("StringItem") | 1 << LayerMask.NameToLayer("Throwable")); raycaster = new Raycaster(this.gameObject, layermask); upRays = new List <Hit> (); downRays = new List <Hit> (); rightRays = new List <Hit> (); leftRays = new List <Hit> (); }
public SelectionManager(RectTransform selectionBox, UserInterface userInterface, Raycaster raycaster) { mSelectionBox = selectionBox; mUserInterface = userInterface; mRaycaster = raycaster; for (int i = 0; i < Groups.Length; i++) { Groups[i] = new SelectionGroup(this, mUserInterface.Root); } }
private void Update() { if (UmpireControl.isGameStarted && !m_isGunInitiated) { m_ammunition.Reload(); m_isGunInitiated = true; } m_reticle.transform.position = Raycaster.GetHitPoint() + Raycaster.GetHitNormal() * 0.001f; m_reticle.transform.rotation = Quaternion.LookRotation(Raycaster.GetHitNormal()); }
void mouseClickHandler(int buttonID) { if (buttonID == MouseButton.LEFT) { RaycastHit hit = Raycaster.getHitByTransform(ground); if (hit.transform != null) { Spawn(hit.point); } } }
// Use this for initialization void Start() { getComponents(); caster = new Raycaster(transform.position, highWallOffset, lowWallOffset, platformOffset); walls = 1 << LayerMask.NameToLayer("Platforms"); moveLeft = Effects.randomBoolValue(); Angery = false; }
private void Awake() { input = PlayerActions.CreateWithDefaultBindings(); raycaster = GetComponent <Raycaster>(); audioManager = FindObjectOfType <AudioManager>(); dudeAnimation = GetComponentInChildren <DudeAnimation>(); UpdateGravity(); velocity = Vector3.zero; respawnPoint = Vector3.zero; }
private void Awake() { if (raycaster == null) { raycaster = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public void ObjectMissed() { //Arrange Raycaster caster = Container.Resolve <Raycaster>(); //Act RaycastResult result = caster.CastRay(Vector3.forward * 2.0f, Vector3.forward); //Assert Assert.That(!result.WasHit); Assert.That(result.HitObject == null); }
void Update() { // Check if there were any objects hit by our reticle-ray cast in the scene. If so, check whether or not // it has a TextureCycler component. if (Raycaster.getInstance().anythingHitByRay()) { GameObject objHitByRay = Raycaster.getInstance().getObjectHitByRay(); string objHitTag = objHitByRay.tag; Debug.Log(objHitTag); // Check that there was a valid object hit by the raycast. Raycaster.getInstance().getObjectHitByRay() // returns null if no objects were hit by ray cast on this frame. Objects responding to input must have // one of the increment/decrement/slideshow tags set to be affected and cycled by raycast. if (objHitByRay != null && isTagValidButton(objHitTag)) { if (TextureObject != null) { for (int i = 0; i < TextureObject.Length; ++i) { TextureCycler objToCycleCycler = TextureObject[i].GetComponent <TextureCycler>(); // Cycle the textures on it! if (objToCycleCycler != null) { if (ButtonsDefineCyclerMode) { objToCycleCycler.setTextureCycleMode(mapTagToModeIndex(objHitTag)); } objToCycleCycler.cycleTextures(); } } } } else if (mapTagToModeIndex(objHitTag) == 2) { togglePause(); } else if (mapTagToModeIndex(objHitTag) == 3) { Debug.Log("Restart clicked"); Application.LoadLevel(Application.loadedLevel); } } if (ScreenFaderSphere.getInstance() && !mFirstTextureReady && TextureLoader.getInstance().isFinishedLoadingFirstTexture()) { mFirstTextureReady = true; ScreenFaderSphere.getInstance().fadeToTransparent(); } }
void updateFreeCorners() { List <Vector3> newList = new List <Vector3>(); foreach (Vector3 c in freeCorners) { if (Raycaster.isFreeCorner(c, maxCornerSize)) { newList.Add(c); } } freeCorners = newList; }
private void Awake() { fillProccess = GetComponent <Image>(); raycaster = FindObjectOfType <Raycaster>(); if (raycaster != null) { raycaster.SelectStatusHandler += ChangeCursor; } else { Debug.LogError("Raycaster is not found!"); } }
protected override void OnLoad(EventArgs e) { string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); Title = String.Format("StoneVox 3D - version {0}", version); GL.Viewport(0, 0, Width, Height); Qfont_1280 = new QFont("data\\fonts\\Bigfish.ttf", 11.2f, new QFontBuilderConfiguration(true, false)); Qfont_1400 = new QFont("data\\fonts\\Bigfish.ttf", 12f, new QFontBuilderConfiguration(true, false)); Qfont_1920 = new QFont("data\\fonts\\Bigfish.ttf", 15, new QFontBuilderConfiguration(true, false)); if (Width <= 1280) { Qfont = Qfont_1280; } else if (Width < 1400) { Qfont = Qfont_1400; } else { Qfont = Qfont_1920; } this.Qfont.Options.Colour = Color.White; //this.Qfont.Options.TransformToViewport = new TransformViewport(-1,-1,2,2); Scale.SetHScaling(0, Width); Scale.SetVScaling(0, Height); ShaderUtil.CreateShader("quad_interpolation", "./data/shaders/QuadInterpolation.vs", "./data/shaders/QuadInterpolation.fs"); broadcaster = new Broadcaster(); manager = new QbManager(broadcaster); input = new Input(this); camera = new Camera(this, input, manager); brushes = new BrushManager(this, input); floor = new Floor(camera, broadcaster); gui = new GUI(this, manager, input); selection = new Selection(this,brushes, input, manager, floor, gui); renderer = new Wireframe(camera, selection, floor, input); undoredo = new UndoRedo(input); selection.GenerateVertexArray(); if(!manager.HasModel) manager.AddEmpty(); camera.LookAtModel(true); backcolor = new Color4(0, 0, 0, 0); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); int ole_hresult = OleInitialize(IntPtr.Zero); IntPtr handle = FindWindowByCaption(IntPtr.Zero, Title); dnd = new DragDropTarget(); int dnd_hresult = RegisterDragDrop(handle, dnd); raycaster = new Raycaster(this, camera, selection, floor, input, manager, gui); selection.raycaster = raycaster; Client.Initialized = true; base.OnLoad(e); SetForegroundWindow(WindowInfo.Handle); }
// ---- inherited handlers ---- void Awake() { if (Raycaster.instance != null) throw new UnityException("Singleton error: instance already set"); // quick and easy singleton Raycaster.instance = this; if (Raycaster.sorter == null) Raycaster.sorter = new RaycastDistanceSorter(); }
//初期化=================================================================== private void StartPhysics() { //接触 GROUND_MASK = 0x1 << LayerMask.NameToLayer(LayerNames.Ground); m_UnderRay = new Raycaster(); m_FrontDownRay = new Raycaster(); m_FrontRay = new Raycaster(); m_Gravity = new GravityStatus(); }