Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Leaderboard


Popular Content

Showing content with the highest reputation on 02/15/2019 in all areas

  1. 1 point
    Just a little script which I have done to help someone recently. It allows to create, using the new UI, a smooth horizontal compass. Regarding the North pole and the player position, it computes a value between -0.5 and 0.5 - exactly what we need so as to set the sprite offset. Put it on your player, set your sprite - no more ++ 0 is the North, 0.25 is the West, -0.5/0.5 is the South, and -0.25 is the East DON'T FORGET - IMAGE WRAP MODE TO "REPEAT" using UnityEngine; using UnityEngine.UI; public class Compass : MonoBehaviour { public RawImage myCompass; void Update() { var lol = MyCompass(new Vector3(this.transform.forward.x, 0, this.transform.forward.z), Vector3.forward, Vector3.up); myCompass.uvRect = new Rect(lol, 0, 1, 1); Debug.Log(lol); } float MyCompass(Vector3 a, Vector3 b, Vector3 n) { float angle = Vector3.Angle(a, b); float sign = Mathf.Sign(Vector3.Dot(n, Vector3.Cross(a, b))); float cmp = (angle * sign)/360; return cmp; // our offset between -0.5 and 0.5 } }
  2. 1 point
    Decided to do something a little different and make an example "Welcome Window" that creates and displays a form welcoming the player. This example requires you to use .Net 2.0 instead of the subset by going to edit>Project Settings>Api Compatibility Level. It also requires System.Drawing.dll and System.Windows.Forms.dll placed in a folder named "Plugins". You can find and copy them from C:/Program Files/Unity/Editor/Data/Mono/lib/mono/2.0. All textures must also a compression to none and read/write enabled. Here is the example: using System.Windows.Forms; using System.Drawing; using System.Collections; using System.Collections.Generic; using UnityEngine; public class WelcomeWindow : MonoBehaviour { public string gameName; public string version; public string gameInfo; public string supportPage = "http://www.armedunity.com"; public Texture2D gameImage; public Texture2D[] screenShots; public Vector2 windowSize = new Vector2(1100, 530); public int splitterPosition = 360; private Form f; private SplitContainer s; public void Start() { Show(); } public void Show() { if (f == null) GenerateForm(); f.ShowDialog(); f.BringToFront(); f.Focus(); } public void Hide() { if (f == null) return; f.Hide(); } public void Dispose() { if (f == null) return; f.Close(); } private void GenerateForm() { PrepareForm(); PreparePanel1(); PreparePanel2(); } private void PrepareForm() { f = new Form(); f.FormBorderStyle = FormBorderStyle.FixedDialog; f.Size = new Size((int)windowSize.x, (int)windowSize.y); f.Text = "Thanks for downloading " + gameName + " " + version + "!"; s = new SplitContainer(); s.Dock = DockStyle.Fill; s.BorderStyle = BorderStyle.Fixed3D; f.Controls.Add(s); } private void PreparePanel1() { s.SplitterDistance = splitterPosition; s.IsSplitterFixed = true; PictureBox p = new PictureBox(); p.Image = ImageFromTexture(gameImage); p.SizeMode = PictureBoxSizeMode.Zoom; p.Location = new Point(0, 0); p.Size = new Size(splitterPosition, splitterPosition); s.Panel1.Controls.Add(p); Label l = new Label(); l.Text = gameInfo; l.Location = new Point(0, splitterPosition); l.AutoSize = false; l.Size = new Size(splitterPosition, (s.Size.Height - splitterPosition) - 45); l.Font = new System.Drawing.Font(FontFamily.GenericSerif, 16); s.Panel1.Controls.Add(l); Button b = new Button(); b.Height = 40; b.Text = "Support Page"; b.Font = l.Font; b.Click += new System.EventHandler(Support); b.Dock = DockStyle.Bottom; s.Panel1.Controls.Add(b); } private void PreparePanel2() { TableLayoutPanel t = new TableLayoutPanel(); t.AutoSize = true; t.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset; t.ColumnCount = 2; t.RowCount = 2; s.Panel2.Controls.Add(t); t.Dock = DockStyle.Fill; for(int x = 0; x < 2; x++) { for(int y = 0; y < 2; y++) { int i = x * 2 + y; if (i >= screenShots.Length) return; if (screenShots[i] == null) continue; PictureBox b = new PictureBox(); b.Image = ImageFromTexture(screenShots[i]); b.Dock = DockStyle.Fill; b.SizeMode = PictureBoxSizeMode.StretchImage; t.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); t.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); t.Controls.Add(b, x, y); } } } private Image ImageFromTexture(Texture2D t) { if (t == null) return null; byte[] byteArray = t.EncodeToPNG(); using (var ms = new System.IO.MemoryStream(byteArray)) { return Image.FromStream(ms); } } private void Support(object sender, System.EventArgs e) { UnityEngine.Application.OpenURL(supportPage); } }
  3. 1 point
  4. 1 point
    Lets Explain the variables: MoveTo - The position of the rotated gun RotateTo - The rotation of the rotated gun Player - Character Controller's GO Layers - Layer to collide with gun Pros: It uses a coroutine to be 10x times faster than in update while using less cpu at the same time If you use a Character Controller: If you use a Capsule Collider of Height 2: Full release of script. It tilts the gun according to your movement.
  5. 1 point
    Hey guys, so I decided to make a thread about the useful scripts that are in this very useful forum. This thread will be updated regularly as soon as I (or you) find some useful scripts. If you found this helpful then leave a "like"! FORMAT: (thread name) by (author of thread) [language (C#/JS)] LIST [@DaBossTMR] Flashlight Script v2.1.1 by DaBossTMR [C#] Bullet Trajectory/Physics by DaBossTMR (credits to Jeremy Clark) [C#] Player Push (less glitchier) by DaBossTMR [C# and JS] [NGUI] Changing Screen Resolutions by DaBossTMR [C#] Top-down Shooter Camera by DaBossTMR [C#] Object Impact Sound by DaBossTMR [C# and JS] Populate Terrain Grass by DaBossTMR [C#] Realistic Camera Shake by DaBossTMR [C#] (credits go to UTnT) Find Closest Transform With Tag by DaBossTMR [C#] Disable ALT-F4 In Game by DaBossTMR [C# and JS] Extended FPS Counter by DaBossTMR [C#] [@OneManArmy] Jeremy Clark's FPS Scripts by OneManArmy [JS] RTS Camera by OneManArmy [JS] Rigidbody Controller by OneManArmy [JS] Buoyancy (Floating Objects) by OneManArmy [C#] Audio Effect When Falling by OneManArmy [JS] Cigarette Smoke Trail by OneManArmy [JS] [@OcularCash] Save/Load Method (Player Prefs) by OcularCash [JS] Health Regeneration by OcularCash [JS] Bouncing Betty/Freddy by OcularCash [JS] COD Style Cooked Grenades by OcularCash [JS] Javelin Script by OcularCash [JS] Stealth Bomber by OcularCash [JS] Harrier with Airstrike by OcularCash [JS] Anti-Spawn Trapping by OcularCash [JS] Predator Missile by OcularCash [JS] Weapon Wheel (GUI) by OcularCash [JS] MW2 Style Semtex Grenade by OcularCash [JS] Team Selection (Private Match) by OcularCash [JS] Flare Gun (with Exploding Rounds) by OcularCash [JS] Explosion (Linear Falloff Damage) by OcularCash [JS] Using Enums To Call Functions by OcularCash [JS] Basic Procedural Player + Movement + Walkable Area by OcularCash [JS] [@Duxducis404] Quake Map Loader (pk3 files) by Duxducis404 [C#] [@YoungDeveloper] Simple Teleport by YoungDeveloper [C#] [@T3kaT0kIkuTa] Particle Magnet by T3kaT0kIkuTa [C#] [@DarkChaos] Wall Avoidance by DarkChaos [JS] Disable Shadows For One Camera by DarkChaos [JS] Improved Sniper Scope System by DarkChaos [JS] Frames Per Second Counter by DarkChaos [JS] Knife Script with Animation Support by DarkChaos [JS] Countdown Timer by DarkChaos [JS] [@themars2011] Extended Timer/Counter by themars2011 [JS] Useful Networking Scripts by themars2011 [JS] Toggle Aim by themars2011 [JS] Mouse Look w/ Custom Editor by themars2011 [JS] [@bxboy15] Weapon Sway/Rotation by bxboy15 [JS] [@ProRussianMn] Save/Load Method (XML) by ProRussianMn [JS] [@jordanblythe104] Weapon Sway Script (Red Orchestra Style) by jordanblythe103 [JS] [@aeditz50] Cinematic Camera Shake by aeditz50 [C#] [@nightbird0] Smart FPS Counter by nightbird0 [C#] [@Epic-Shot] Fullscreen Video Using GUI (Pro Only) by Epic-Shot [C#] [@loftail] Zombie AI (Pro Only) by loftail [JS] [@dreadt9] Sentry Gun by dreadt9 [JS] l4mishotiz (Unity Forums) FPS Starter Scripts by l4mishotiz [uNKNOWN] [@jediaction] Peek Script by jediaction [JS] SIMPLE SCRIPTS/TOOLS Simple Tips System by pspdude [JS] Javascript to C# Converter by M2H [C# people]
×
×
  • Create New...