🤑 Indie game store🙌 Free games😂 Fun games😨 Horror games
👷 Game development🎨 Assets📚 Comics
🎉 Sales🎁 Bundles

PSPiso

4
Posts
1
Topics
A member registered Oct 09, 2015 · View creator page →

Games

Recent community posts

Works well in Firefox. Nice concept too.

(Edited 1 time)

At the end I was trying to add more ground units like tanks and such. And also add the Noxious gas/acid vials aswell as add the rocket barrage. But this project will likely be a side project when ever I have the time to patch it up as I'm busy on a bigger racing game. Also I need to fix the HTML5 port as the gravity seems to be twice as heavy as normal (in Editor/EXE release).

Also was planning on adding technology scaling from smashing rocks to metal to 3d printing.

TL:DR
Yes, someday.

//2D movement in 3D environment
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GroundUnitMovement : MonoBehaviour {

    //General Variables
    public GameObject ammo;
    private List<GameObject> Targets = new List<GameObject>();
    public float scale_left = 0;
    public float scale_right = 0;
    public GameObject sprite = null;

    //Control Variables
    public float attack_Range = 0;
    public float var_AutoX = 0;
    public float speed;
    private Rigidbody rigidbody_val = null;
    private bool onGround = false;
    
    void Start() {
        //Set rigidbody
        this.rigidbody_val = this.GetComponent<Rigidbody>();
    }
    
    void Update() {
        //Check for destroyed player objects in list
        this.UpdateTargetList();
        //Check for player objects in radius
        this.CheckSurrounding();

        //all targets are located at x-coord: 0. Replace 0 with Target[0].position.x if needed.
        if (Targets.Count == 0)
        {
            if (this.transform.position.x > 0)
            {
                this.var_AutoX = -this.speed;
                //this.sprite.transform.rotation.eulerAngles.Set(0, scale_left, 0);

                this.sprite.transform.rotation = new Quaternion(0, scale_left, 0, 1);

                Debug.Log(this.sprite.transform.rotation);
            }
            if (this.transform.position.x < 0)
            {
                this.var_AutoX = this.speed;

                this.sprite.transform.rotation = new Quaternion(0, scale_right, 0, 1);
                
                //this.sprite.transform.rotation.eulerAngles.Set(0, scale_right, 0);
                Debug.Log(this.sprite.transform.rotation);
            }

            //Movement is only allowed when the character is on the ground and has not targets in sight.
            if (this.onGround)
            {
                this.rigidbody_val.AddForce(new Vector3(this.var_AutoX, 0), ForceMode.Impulse);
            }
        }
        else
        {
            //Attack first unit in the list - The first encountered player object and or player. 
            //Will not target the player when he/she stands before the object but can attack it cause of the bullets passing him/her.

            //create projectile.
            Fire(Targets[0].transform.position);
        }

    }

//Creates a circular collider and records all entities within this circle.
    void CheckSurrounding()
    {
        Collider[] hitTargets = Physics.OverlapSphere(this.transform.position, attack_Range);
        Debug.DrawLine(this.transform.position, this.transform.position + new Vector3(attack_Range, 0), Color.blue);
        Debug.DrawLine(this.transform.position, this.transform.position + new Vector3(-attack_Range, 0), Color.blue);
        foreach (Collider c in hitTargets)
        {
            //When the object in the collider doesn't exist add to the target list.
            if (c.tag == "Player" || c.tag == "playerObj")
            {
                if (!Targets.Contains(c.gameObject))
                {
                    Targets.Add(c.gameObject);
                }
            }
        }
    }

    void Fire(Vector3 target)
    {
        //Rotate firing object towards target.
        Quaternion rotation = Quaternion.FromToRotation(this.transform.position, target);
        //Create new instance of object.
        GameObject.Instantiate(ammo, this.transform.position, rotation);
    }

    void UpdateTargetList()
    {
        List<GameObject> newList = new List<GameObject>();
        foreach(GameObject go in this.Targets)
        {
            //if not destoyed add to the temp list.
            if(go != null)
            {
                newList.Add(go);
            }
        }
        if(this.Targets.Count != newList.Count)
        {
            this.Targets = newList;
        }
    }

    void FixedUpdate()
    {
        //Check if unit is on the ground
        this.IsOnGround();
    }

//Requires a surface with the tag floor to work.
    void IsOnGround()
    {
        //always false unless unit collides with floor;
        this.onGround = false;

        Ray ray_floor = new Ray(this.transform.position,
                          -this.transform.up);
        RaycastHit hit_floor;

        Debug.DrawRay(this.transform.position,
                          -this.transform.up);
        if (Physics.Raycast(ray_floor,
                            out hit_floor,
                            (this.transform.lossyScale.y / 2 + 0.05f)))
        {
            if (hit_floor.transform.tag == "floor") 
            {
                this.onGround = true;
            }
        }
    }
}
//Scrolling Textures
using UnityEngine; using System.Collections; public class HorizontallyScrollingTextures : MonoBehaviour { public float horizontalScrollSpeed, verticalScrollSpeed = 0.5f; private Mesh mesh; void Start() { mesh = GetComponent<MeshFilter>().mesh; } void Update() { SwapUVs(); } void SwapUVs() { Vector2[] uvSwap = mesh.uv; for (int i = 0; i < uvSwap.Length; i ++) { uvSwap[i] += new Vector2( horizontalScrollSpeed * Time.deltaTime, verticalScrollSpeed * Time.deltaTime ); } mesh.uv = uvSwap; } }
Created a new topic [Continued?] Civil Growth
(Edited 2 times)

Kinda wanted to go heads deep into this but from the 48 hours I would end up with half of it cause of work. Think I'd only have my spritesheets finished before the end of tomorrow if I were to continue. Ah well if someone is in need for some resources be my guest, do note that I was building in C# and Unity:
Unfinished progress[Video]

Might finish something tomorrow if I have the time for it.

*Update*
Some 7 hours left, attempting to continue.

Stream A new hope for luck.