public void RunFloppyWithOutHeld(FloppySensor sensor) { Rigidbody rb = GetComponent <Rigidbody>(); HeldItem hd = GameObject.Find("Character").GetComponent <Character>().HeldItem; if (hd.Rb == rb) { hd.Deattach(); } Debug.Log("RunFloppyWithOutHeld.1 true"); rb.isKinematic = true; rb.detectCollisions = false; transform.SetParent(sensor.transform, true); PosA = transform.localPosition; PosB = new Vector3(0, 0, -1.0f); PosC = new Vector3(0, 0, 0.25f); RotA = transform.localRotation; RotB = Quaternion.Euler(180, 0, -90); Time = 0.0f; MaxTime = 0.5f; State = 1; Direction = 1; //transform.localPosition = new Vector3(0,0, 0.25f); //transform.localRotation = Quaternion.Euler(180,0,-90); }
public void dropItem(HeldItem item) { item.transform.parent = world; Rigidbody2D rb = item.transform.GetComponent <Rigidbody2D>(); rb.simulated = true; }
void Update() { Ray ray = new Ray(transform.position, transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, interactDistance, interactLayer)) { if (isInteracting == false) { panel.SetActive(true); if (Input.GetButtonDown(interactButton)) { if (hit.collider.CompareTag("DoorOpen")) { hit.collider.GetComponent <DoorOpen>().ChangeDoorState(); } if (hit.collider.CompareTag("Cube")) { HeldItem.pickUpItem(hit.collider.gameObject.name, hit.collider.gameObject); } } } } else { panel.SetActive(false); } }
//Item pickup/drop action private void PickDropItem() { Item nearest = GetFirstItemInSight(Direction, Range); //Take item if none is currently being held if (HeldItem == null) { if (nearest != null) { HeldItem = nearest.PickUp(this); ApplyItemProperties(); } } //Drop held item or swap items if available else { if (nearest == null) { HeldItem.PutDown(Direction); DisapplyItemProperties(); HeldItem = null; } else { Item heldTmp = HeldItem; DisapplyItemProperties(); //disapply the previous item HeldItem = nearest.PickUp(this); heldTmp.PutDown(Direction); ApplyItemProperties(); //apply the new item } } }
public void EquipItem(int index) { if (currentItem && !currentItem.canSwitch) { return; } if (currentItem != null) { currentItem.gameObject.SetActive(false); } currentItem = null; for (int i = 0; i < items.Count; i++) { if (i == index) { items[i].gameObject.SetActive(true); currentItem = items[i]; currentItem.OnEquip(this); } else { items[i].gameObject.SetActive(false); } } }
public void InvokeUse() { if (HeldItem != null) { HeldItem.Use(); } }
public virtual void Draw(SpriteBatch sb, Color color) { Color tint = color; if (State is AttackingUpLinkState) { this.origin = new Vector2(0, 15); } else if (State is AttackingLeftLinkState) { this.origin = new Vector2(10, 0); } else if (State is LinkPickupState) { HeldItem.Draw(sb, Microsoft.Xna.Framework.Color.White); this.origin = new Vector2(0, 0); } else { this.origin = new Vector2(0, 0); } if (State is LinkDeadState) { tint = this.DeadColor; } Sprite.Draw(sb, tint, origin); }
public int frozenFrame = 0; // The frame that the character is frozen until (after resets, etc). public Character(RoomScene room, byte subType, FVector pos, Dictionary <string, short> paramList) : base(room, subType, pos, paramList) { this.Meta = Systems.mapper.ObjectMetaData[(byte)ObjectEnum.Character].meta; this.SetSpriteName("Stand"); // Physics, Collisions, etc. this.AssignBounds(8, 12, 28, 44); this.physics = new Physics(this); this.physics.SetGravity(FInt.Create(0.7)); // Default Stats & Statuses this.stats = new CharacterStats(this); this.status = new CharacterStatus(); this.wounds = new CharacterWounds(this); // Attachments this.trailKeys = new TrailingKeys(this); this.heldItem = new HeldItem(this); this.magiShield = new MagiShield(this); this.nameplate = new Nameplate(this, "Lana", false, false); // Images and Animations this.animate = new Animate(this, "/"); // Reset Character, Set Default Values this.ResetCharacter(); // Assign SubTypes and Params this.AssignSubType(subType); this.AssignParams(paramList); }
/// <summary> /// Removes a certain amount of the item in the inventory slot /// </summary> /// <param name="amount"></param> /// <returns> This returns the item with the amount that was removed, whatever was left stays inn the inventory slot</returns> public override Item RemoveItem(int amount = 1) { Item temp = Instantiate(HeldItem, HeldItem.transform); temp.transform.parent = null; SlotWeight -= HeldItem.itemWeight * amount; ParentInventory.ReduceWeight(HeldItem.itemWeight * amount); if (amount > HeldItem.stackCount) { amount = HeldItem.stackCount; } if (amount == HeldItem.stackCount) { Destroy(HeldItem.gameObject); HeldItem = null; } else { if (temp.stackCount - amount > 0) { temp.RemoveFromStack(temp.stackCount - amount); } HeldItem.RemoveFromStack(amount); } SetHeldItem(); UpdateItemDisplay(); return(temp); }
public void WarpFloppy(FloppySensor sensor) { Rigidbody rb = GetComponent <Rigidbody>(); HeldItem hd = GameObject.Find("Character").GetComponent <Character>().HeldItem; if (hd.Rb == rb) { hd.Deattach(); } Debug.Log("WarpFloppy.1 true"); rb.isKinematic = true; rb.detectCollisions = false; transform.SetParent(sensor.transform, true); transform.localPosition = new Vector3(0, 0, 0.25f); //Vector3.Lerp(PosB, PosC, Time / MaxTime); transform.localRotation = Quaternion.Euler(180, 0, -90); sensor.IsEmpty = false; sensor.Floppy = this; DX8.dx8 dx8 = GameObject.Find("DX8").GetComponent <DX8.dx8>(); dx8.SetEjectButton(true); }
public override void Update() { base.Update(); if (isBouncing) { isBouncing = false; } if (returnToUser) { if (heldItem == null) { heldItem = GetComponent <HeldItem>(); } var vectorToTarget = returnTarget.position - transform.position; var angleToTarget = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg; var quaternionToTarget = Quaternion.AngleAxis(angleToTarget, Vector3.forward); transform.localRotation = Quaternion.Slerp(transform.rotation, quaternionToTarget, Time.deltaTime * rotateSpeed); DistanceCheck(heldItem.User); } else { if (speed < returnThresholdSpd) { SetReturnState(true); } } }
void OnItemDropped() { if (currentItem != null) { currentItem.Drop(); currentItem = null; Messenger.Broadcast<HeldItem>("heldItem", null); } }
private void DropItem(ActivatedItem item) { HeldItem.showItem(); HeldItem.tag = "Item"; HeldItem.transform.position = transform.position + new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); HeldItem.transform.parent = returnToRoom(); // Back in Room HeldItem.transform.rotation = Quaternion.Euler(0, 0, 0); updateCache(HeldItem); }
void AddHeldItem(object sender, object args) { HeldItem acquiredItem = args as HeldItem; // TODO Maybe eventually implement pooling for icons? Slot1Item = Instantiate(acquiredItem); Slot1Item.transform.SetParent(Slot1); Slot1Item.transform.localPosition = Vector3.zero; }
public void activateItem() { if (HeldItem != null && !HeldItem.isOnCooldown) { HeldItem.activateItem(); onItemUse?.Invoke(HeldItem); ItemUseEvent?.Invoke(); } }
/// <summary> /// Pick up an item. /// </summary> /// <param name="item"></param> private void PickUpItem(HeldItem item) { m_heldItem = item; item.PickUp(); // Set the item's parent. item.transform.parent = HeldItemBone.transform; item.transform.localPosition = Vector3.zero; }
/// <summary> /// Drop the item. /// </summary> private void DropItem() { // Un-parent the item. m_heldItem.transform.parent = null; m_heldItem.Drop(); // Clear the held item. m_heldItem = null; }
public void PickUpItem(HeldItem h) { bool tf = false; Type t = h.GetType(); HeldItem thing = null; foreach (HeldItem go in items) { // print("T: " + t.ToString() + " curr: " + go.GetType().ToString()); if (go.GetType() == t) { tf = true; thing = go; break; } } if (tf) { // print("Here"); thing.OnPickUpSecondItem(h); Destroy(h.gameObject); } else { h.OnPickup.Invoke(); h.transform.SetParent(hand); h.transform.localPosition = Vector3.zero; h.transform.localRotation = Quaternion.identity; items.Add(h); h.gameObject.SetActive(false); h.transform.GetChild(0).localPosition = h.posOffset; h.transform.GetChild(0).localRotation = Quaternion.Euler(h.rotationOffset); h.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; if (currentItem == null) { EquipItem(0); } if (h.GetComponent <Billboard>()) { Destroy(h.GetComponent <Billboard>()); } ItemButton i = Instantiate(itemButtonPrefab, buttonSpot); i.init(h.icon, h); buttons.Add(i); h.itemButton = i; h.OnInitialSetup(this); } }
void ItemUse() { if (Input.GetKey(KeyCode.E)) { if (Item1 != null) { Item1.UseItem(); Item1 = null; } } }
public LaneItem(HeldItem heldItem, Lane lane) : base("Lane" + heldItem.conveyorItem.type.ToString(), lane) { effectsOverride = new List <Definitions.Effects>(); body.transform.localScale = new Vector3(heldItem.conveyorItem.width, 1, heldItem.conveyorItem.height); meshRenderer.material.color = Color.white; label.SetText(heldItem.conveyorItem.text); position = lane.end + (Vector3.up * 0.5f) + (Vector3.left * body.transform.localScale.x * 0.5f); this.heldItem = heldItem; }
public void EquipItem(HeldItem h) { if (items.Contains(h)) { EquipItem(items.IndexOf(h)); } else { Debug.LogError("COULD NOT FIND ITEM IN IVENTORY"); } }
//destroy is delayed to end of current frame, so we use a coroutine //clear any child object before instantiating the new one IEnumerator ChangeItem(HeldItem newItem) { //if this object has a child, destroy them while (transform.childCount > 0) { Destroy(transform.GetChild(0).gameObject); yield return(null); } //use the new value SetObjToSpawn(newItem); }
public void pickupOrDrop() { if (heldItem != null) { pickup.dropItem(heldItem); heldItem = null; } else { heldItem = pickup.pickupItem(holdPosition); } }
private void OnEnable() { if (gameObjectItem == null) { gameObjectItem = GetComponent <HeldItem>(); } if (ic == null) { gameObjectItem.onStart.AddListener(Init); } }
// Remembers the saved item if it existed public override void RememberHeldItem() { ItemIDHeld = PlayerPrefs.GetString("GauntletsID" + SlotNumber, "None"); if (ItemIDHeld == "None") { //Debug.Log("Nothing Loaded; ID: 'None'"); SlotWeight = 0; ItemsHeld = 0; } else { ItemsHeld = PlayerPrefs.GetInt("GauntletsCount" + "" + SlotNumber, 1); string[] str = ItemIDHeld.Split('-'); ItemCatalogue cat = Resources.Load <ItemCatalogue>("Prefabs/Items/Catalogue/" + str[0]); if (cat != null) { cat = Instantiate(cat); //Debug.Log(cat.gameObject.name + " Loaded"); if (cat.FindObjectID(str[0], int.Parse(str[1])) != null) { HeldItem = Instantiate(cat.FindObjectID(str[0], int.Parse(str[1]))); } if (HeldItem != null) { //Debug.Log(HeldItem.gameObject.name + " Loaded (ID: " + HeldItem.itemID + ")"); HeldItem.transform.parent = ParentInventory.transform; HeldItem.transform.localPosition = Vector3.zero; } } if (HeldItem == null) { string Name = PlayerPrefs.GetString(ItemIDHeld); Item folderItem = Resources.Load <Item>("Prefabs/Items/" + Name + ".prefab"); if (folderItem != null) { HeldItem = Instantiate(folderItem, ParentInventory.transform); } } Destroy(cat.gameObject); if (HeldItem != null) { Durability = PlayerPrefs.GetInt("GauntletID_Durability" + SlotNumber, Durability); SetDurability(Durability); HeldItem.SetStack(ItemsHeld); ItemsHeld = HeldItem.stackCount; SetHeldItem(); HeldItem.DeactivateItem(); } } UpdateItemDisplay(); }
void Start() { hi = gameObject.GetComponentInChildren<HeldItem> (); if (hi == null) { Destroy(this.gameObject); } hi.hazardCollider = gameObject.GetComponentInChildren<PolygonCollider2D> (); hi.forceHazard = true; hit = false; grabbed = false; countdown = 10f; rigid = gameObject.GetComponent<Rigidbody2D> (); }
//Called by the attacked when this entity is hit by an attack - decreses HP, decides whether entity dies, counts combat statistics public void TakeDamage(Entity source, float damage) { //Defense property decreases damage taken var realDamage = (int)(damage - Defense); if (realDamage > 0) { HP -= realDamage; if (IsPlayer) //add to stats { ((Player)this).Stats.DamageSustained += realDamage; } //When damaged, entity flashes red for 200ms OverwriteColor = Color.Red; map.EntityEvents.AddEvent(new Event <Entity>(200, delegate(Entity e) { e.OverwriteColor = Color.White; }, this)); UpdateOutlineColor(); } else { //If attack was deflected, entity flashes gray for 200ms OverwriteColor = Color.DarkGray; map.EntityEvents.AddEvent(new Event <Entity>(200, delegate(Entity e) { e.OverwriteColor = Color.White; }, this)); } if (HP <= 0) { Alive = false; //now Map Update check will recognise this NPC as dead and will remove it. //Drop current item when dead if (HeldItem != null) { HeldItem.PutDown(Direction); DisapplyItemProperties(); HeldItem = null; } //Add statistics if (IsPlayer) { ((Player)this).Stats.TimesDead++; FillHP(); } if (source.IsPlayer) { ((Player)source).Stats.EnemiesKilled++; } } }
/// <summary> /// This method checks to make sure we have a casting device equipped and if so, it sets /// the motion state and sends the messages to switch us to spellcasting state. Og II /// </summary> public void HandleSwitchToMagicCombatMode() { HeldItem mEquipedWand = Children.Find(s => s.EquipMask == EquipMask.Held); if (mEquipedWand != null) { UniversalMotion mm = new UniversalMotion(MotionStance.Spellcasting); mm.MovementData.CurrentStyle = (uint)MotionStance.Spellcasting; SetMotionState(this, mm); CurrentLandblock.EnqueueBroadcast(Location, Landblock.MaxObjectRange, new GameMessagePrivateUpdatePropertyInt(Sequences, PropertyInt.CombatMode, (int)CombatMode.Magic)); } else { log.InfoFormat("Changing combat mode for {0} - could not locate a wielded magic caster", Guid); } }
void OnItemUsed(Transform itemTransform) { HeldItem heldItem = null; foreach(HeldItem item in allItems) { if (itemTransform == item.worldItem) { heldItem = item; break; } } if (heldItem != null) { if (currentItem != null) { currentItem.Drop(); } currentItem = heldItem; heldItem.gameObject.SetActive(true); Messenger.Broadcast<HeldItem>("heldItem", heldItem); } }
/// <summary> /// Handle selecting and picking up items. /// </summary> private void HandlePickingUpItems() { if (m_heldItem != null) { return; } // Look at an item. HeldItem selectedItem = null; GrabFailReason reason = GrabFailReason.Range; RaycastHit hitInfo; if (Physics.Raycast(PlayerCamera.transform.position, PlayerCamera.transform.forward, out hitInfo, PickupItemDistance * Scale, LayerMask.GetMask("HeldItem"))) { HeldItem lookedAtItem = hitInfo.transform.GetComponent <HeldItem>(); if (lookedAtItem == null) { lookedAtItem = hitInfo.transform.GetComponentInParent <HeldItem>(); } if (CanSelectItemBasedOnScale(lookedAtItem, out reason)) { selectedItem = lookedAtItem; lookedAtItem.SetSelectionVisual(true); } else { lookedAtItem.SetSelectionVisual(false); } } // If a valid item is looked at, you can pick it up with a button. if (Input.GetButtonDown("Grab") && !m_grabbedThisFrame) { m_grabbedThisFrame = true; if (selectedItem == null) { GameManager.Instance.GameCanvas.PlayGrabFailAnimation(reason); } else { PickUpItem(selectedItem); } } }
// Saves the item public override void SetHeldItem() { if (HeldItem != null) { ItemIDHeld = HeldItem.itemID; ItemsHeld = HeldItem.stackCount; HeldItem.RememberName(); PlayerPrefs.SetString("GauntletsID" + SlotNumber, ItemIDHeld); PlayerPrefs.SetInt("GauntletsCount" + SlotNumber, ItemsHeld); //Debug.Log("SlotID" + SlotNumber + " ID Saved: " + ItemIDHeld + ", Amount: " + ItemsHeld); } else { PlayerPrefs.SetString("GauntletsID" + SlotNumber, "None"); PlayerPrefs.SetInt("GauntletsCount" + SlotNumber, 0); } SetDurability(Durability); }
public void Split() { HeldItem upHeldItem = new HeldItem(new ConveyorItem(lane.stage.conveyor, Definitions.Item(Definitions.Items.Part), heldItem.conveyorItem.settings)); LaneItem upItem = new LaneItem(upHeldItem, lane); upHeldItem.conveyorItem.Destroy(); upHeldItem.Destroy(); lane.Add(upItem); upItem.SetPosition(new Vector3(position.x, upItem.position.y, upItem.position.z)); upItem.changeLane = upItem.ChangeLane(-1); HeldItem downHeldItem = new HeldItem(new ConveyorItem(lane.stage.conveyor, Definitions.Item(Definitions.Items.Part), heldItem.conveyorItem.settings)); LaneItem downItem = new LaneItem(downHeldItem, lane); downHeldItem.conveyorItem.Destroy(); downHeldItem.Destroy(); lane.Add(downItem); downItem.SetPosition(new Vector3(position.x, downItem.position.y, downItem.position.z)); downItem.changeLane = downItem.ChangeLane(1); }
/// <summary> /// This method is called if we unwield missle ammo. It will check to see if I have arrows wielded /// send the message to "hide" the arrow. /// </summary> /// <param name="oldCombatMode"></param> public void HandleUnloadMissileAmmo(CombatMode oldCombatMode) { // Before I can switch to any non missile mode, do I have missile ammo I need to remove? WorldObject ammo = null; HeldItem mEquipedAmmo = Children.Find(s => s.EquipMask == EquipMask.MissileAmmo); if (mEquipedAmmo != null) { ammo = GetInventoryItem(new ObjectGuid(mEquipedAmmo.Guid)); } if (oldCombatMode == CombatMode.Missile) { if (ammo != null) { ammo.Location = null; CurrentLandblock.EnqueueBroadcast(Location, Landblock.MaxObjectRange, new GameMessagePickupEvent(ammo)); } } }
// Use this for initialization void Start() { heldItem = this.GetComponent<HeldItem>(); }
void Start() { myHeldItem = this.GetComponent<HeldItem>(); //print ("starting off my thing"); startTime = time; Collider2D[] cols = GetComponents<Collider2D> (); if (!hitsSourcePlayer && sourcePlayer != null) { foreach (Collider2D col in cols) { Physics2D.IgnoreCollision (sourcePlayer.GetComponent<PolygonCollider2D> (), col, true); } } }
void OnHeldItem(HeldItem item) { heldItem = item; }
void OnHeldItemUsed(HeldItem item) { if (item == currentItem) { item.Use(); } }
public void HoldItem(HeldItem hi) { heldItem = hi; }
// Use this for initialization void Start() { timeSincelast = timeToShoot; if (chargedShot) { maxProjectileSpeed = projectileSpeed; projectileSpeed = 0; } chargeTime = minChargeTime; butthole = transform.FindChild("Butthole"); gunbase = transform.FindChild("GunBase"); myHeldItem = this.GetComponent<HeldItem>(); Transform smoke, flare; if (smoke = transform.FindChild("ParticleSmoke")) particleSmoke = smoke.GetComponent<ParticleSystem>(); isrpg = true; if (transform.name != "RPG") isrpg = false; if (isrpg == false) { if (flare = transform.Find("ParticleMuzzleFlare")) particleMuzzleFlare = flare.GetComponent<ParticleSystem>(); } else { if (flare = transform.Find("ParticleMuzzleFlareRPG")) particleMuzzleFlare = flare.GetComponent<ParticleSystem>(); } }
void Update() { if (transform.position.y < -30) Die (); if (heldItem != null) { heldItem.transform.position = new Vector3(transform.position.x, transform.position.y+1.4f, transform.position.z); } isWalking = Mathf.Abs(rigidbody2D.velocity.x) < 1 ? false : true; if (!isEnlightened) { if (!checkGrounded()) { rigidbody2D.drag = 2; }else { rigidbody2D.drag = 10; } if (Input.GetKey(KeyCode.RightArrow)) { facingLeft = false; rigidbody2D.AddForce(new Vector2(70, 0)); if (rigidbody2D.velocity.x > maxSpeed) rigidbody2D.velocity = new Vector2(maxSpeed, rigidbody2D.velocity.y); if (isGhost) rigidbody2D.velocity = new Vector2(maxSpeed, rigidbody2D.velocity.y); if (checkGrounded()) { if (isWalking) { UpdateFootstep(); } else { footStepAudSource.Play(); } } if (levitationScript != null) levitationScript.checkLevatation(); } else if (Input.GetKey(KeyCode.LeftArrow)) { facingLeft = true; rigidbody2D.AddForce(new Vector2(-70, 0)); if (rigidbody2D.velocity.x < -maxSpeed) rigidbody2D.velocity = new Vector2(-maxSpeed, rigidbody2D.velocity.y); if (isGhost) rigidbody2D.velocity = new Vector2(-maxSpeed, rigidbody2D.velocity.y); if (checkGrounded()) { if (isWalking) { UpdateFootstep(); } else { footStepAudSource.Play(); } } if (levitationScript != null) levitationScript.checkLevatation(); } } if (Input.GetKeyDown(KeyCode.Space)) { if (heldItem != null) { if (heldItem.GetComponent<Bunny>() != null) { heldItem.GetComponent<Bunny>().PlayThrowSound(); } float horizOffset = 1.8f; if (facingLeft) horizOffset *= -1; heldItem.rigidbody2D.velocity = new Vector2(); heldItem.transform.position = new Vector3(transform.position.x+horizOffset, transform.position.y, transform.position.z); heldItem.unHold (); heldItem = null; }else if (HasItem("weapon")) { if (heldItem != null) { float horizOffset = 0; if (facingLeft) horizOffset = -1.4f; else horizOffset = 1.4f; heldItem.transform.position = new Vector3(transform.position.x+horizOffset, transform.position.y, transform.position.z); heldItem = null; }else { UsedItem item = itemsDict["weapon"]; //itemsDict.TryGetValue("weapon", out item); UsedItem usedItem = (UsedItem)Instantiate(item, transform.position, Quaternion.identity); usedItem.SetItemUser(this); } } } if ((checkGrounded() || isGhost) && Input.GetKey(KeyCode.UpArrow)) { rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, jumpForce); if (karma != -1) PlaySound("jump"); if (levitationScript != null) levitationScript.checkLevatation(); } if (Input.GetKey(KeyCode.DownArrow) && isGhost) { rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, -jumpForce); } if (Input.GetKeyDown(KeyCode.R)) { Application.LoadLevel(Application.loadedLevel); } //Flip direction if (!isEnlightened) { if ((Input.GetKeyDown(KeyCode.LeftArrow))) { print (facingLeft); if (!isImageFacingLeft) { isImageFacingLeft = !isImageFacingLeft; transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, 1); } } if ((Input.GetKeyDown(KeyCode.RightArrow))) { print (!isImageFacingLeft); if (isImageFacingLeft) { isImageFacingLeft = !isImageFacingLeft; transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, 1); } } } if (frozen == true) { rigidbody2D.velocity = Vector2.zero; } if (isGhost) { rigidbody2D.velocity *= .9f; /* float vertExtent = Camera.main.camera.orthographicSize; float horzExtent = vertExtent * Screen.width / Screen.height; // Calculations assume map is position at the origin float minX = Camera.main.transform.position.x - horzExtent/2f; float maxX = Camera.main.transform.position.x + horzExtent/2f; float minY = Camera.main.transform.position.y - vertExtent/2f; float maxY = Camera.main.transform.position.y + vertExtent/2f; var v3 = transform.position; v3.x = Mathf.Clamp(v3.x, minX, maxX); v3.y = Mathf.Clamp(v3.y, minY, maxY); transform.position = v3; */ } }