There she be
code :)
Restarterusing UnityEngine;
//brings player back to starting position via collision //given by sample assests but adjusted namespace UnitySampleAssets._2D { public class Restarter : MonoBehaviour { private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") Application.LoadLevel(Application.loadedLevelName); } } } Platformer2dusercontrolusing UnityEngine;
//using UnitySampleAssets.CrossPlatformInput; //takes usercontrols to be used in the chara script //provided by sample assests namespace UnitySampleAssets._2D { [RequireComponent(typeof (PlatformerCharacter2D))] public class Platformer2DUserControl : MonoBehaviour { private PlatformerCharacter2D character; private bool jump; private void Awake() { character = GetComponent<PlatformerCharacter2D>(); } private void Update() { if(!jump) // Read the jump input in Update so button presses aren't missed. jump = Input.GetButtonDown("Jump"); } private void FixedUpdate() { // Read the inputs. bool crouch = Input.GetKey(KeyCode.LeftControl); float h = Input.GetAxis("Horizontal"); // Pass all parameters to the character control script. character.Move(h, crouch, jump); jump = false; } } } NextLevelusing System.Collections;
using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; //going from one level to the next via collision //written by me public class NextLevel : MonoBehaviour { //lets me input each level i want to get to manually in unity public string level; //private Scene nextLevel = SceneManager.Scene2 //UnityEngine.SceneManagement.Scene.Scene2; private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") //i was trying to create a delay new WaitForSecondsRealtime(5.0f); //loads the specified level Application.LoadLevel(level); } } Camerafollowattemptusing System.Collections;
using System.Collections.Generic; using UnityEngine; //follows the player in the x value only //written by me public class CameraFollowAttempt : MonoBehaviour { //defining what will do they following aka camera public Transform FollowPlatform; //defining what will be followed public Transform Player; void Update () { //updates the camera with the position of the player, following x and staying at a y of 0 FollowPlatform.position = new Vector3(Player.position.x, 0, -10); } } idk if thisll work??
IT DOESNT WORK http://www.mediafire.com/file/ys6dk84n6s5l1wp/NoText.exe aRRAYSCRIPT//puts the backgrounds (tagged background) into an array
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ArrayScript : MonoBehaviour { public GameObject[] myBackgroundArray = { }; // Use this for initialization void Start () { myBackgroundArray = GameObject.FindGameObjectsWithTag("Background"); } // Update is called once per frame void Update () { } } http://www.mediafire.com/?x6iin5963ub7a
this one should work |
PlatformerCharacter2dusing UnityEngine;
//moving and checking and everything for chara //given by sample assests but adjusted by me since some terms were out of date and wouldn't work namespace UnitySampleAssets._2D { public class PlatformerCharacter2D : MonoBehaviour { private bool facingRight = true; // For determining which way the player is currently facing. [SerializeField] private float maxSpeed = 10f; // The fastest the player can travel in the x axis. [SerializeField] private float jumpForce = 400f; // Amount of force added when the player jumps. [Range(0, 1)] [SerializeField] private float crouchSpeed = .36f; // Amount of maxSpeed applied to crouching movement. 1 = 100% [SerializeField] private bool airControl = false; // Whether or not a player can steer while jumping; [SerializeField] private LayerMask whatIsGround; // A mask determining what is ground to the character private Transform groundCheck; // A position marking where to check if the player is grounded. private float groundedRadius = .2f; // Radius of the overlap circle to determine if grounded private bool grounded = false; // Whether or not the player is grounded. private Transform ceilingCheck; // A position marking where to check for ceilings private float ceilingRadius = .01f; // Radius of the overlap circle to determine if the player can stand up private Animator anim; // Reference to the player's animator component. private Rigidbody2D rb; private void Awake() { // Setting up references. groundCheck = transform.Find("GroundCheck"); ceilingCheck = transform.Find("CeilingCheck"); anim = GetComponent<Animator>(); //!!!!!!!!!! rb = GetComponent<Rigidbody2D>(); //stuckText.text = ""; } private void FixedUpdate() { // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground grounded = Physics2D.OverlapCircle(groundCheck.position, groundedRadius, whatIsGround); anim.SetBool("Ground", grounded); // Set the vertical animation anim.SetFloat("vSpeed", rb.velocity.y); } public void Move(float move, bool crouch, bool jump) { // If crouching, check to see if the character can stand up if (!crouch && anim.GetBool("Crouch")) { // If the character has a ceiling preventing them from standing up, keep them crouching if (Physics2D.OverlapCircle(ceilingCheck.position, ceilingRadius, whatIsGround)) crouch = true; } // Set whether or not the character is crouching in the animator anim.SetBool("Crouch", crouch); //only control the player if grounded or airControl is turned on if (grounded || airControl) { // Reduce the speed if crouching by the crouchSpeed multiplier move = (crouch ? move*crouchSpeed : move); // The Speed animator parameter is set to the absolute value of the horizontal input. anim.SetFloat("Speed", Mathf.Abs(move)); // Move the character rb.velocity = new Vector2(move*maxSpeed, rb.velocity.y); // If the input is moving the player right and the player is facing left... if (move > 0 && !facingRight) // ... flip the player. Flip(); // Otherwise if the input is moving the player left and the player is facing right... else if (move < 0 && facingRight) // ... flip the player. Flip(); } // If the player should jump... if (grounded && jump && anim.GetBool("Ground")) { // Add a vertical force to the player. grounded = false; anim.SetBool("Ground", false); rb.AddForce(new Vector2(0f, jumpForce)); } } private void Flip() { // Switch the way the player is labelled as facing. facingRight = !facingRight; // Multiply the player's x local scale by -1. Vector3 theScale = transform.localScale; theScale.x *= -1; transform.localScale = theScale; } //trying to figure out colliders on my own, realizing i wanted them not on the player ///private void OnTriggerEnter2D(Collider other) //{ //if (other.gameObject.CompareTag("Stuck Message")) ///{ /// other.gameObject.SetActive(true); //} // } } } |
here it isSo for my project I plan on creating a game in the Unity Game Engine.
My idea is to create a simple 6 stage 2D platformer using resources from the Asset Store and coding in C#. To do this I need to further my knowledge with Unity and scream a bit probably. Well I suppose the second bit isn't a need but it'll probably happen. Using tutorials and other resources I can pull together,, I'm just praying for the best D: Update 05/24/17: While working with the resources I found it too challenging to use the meat man avatar from the one asset pack, so I imported the Unity Technologies basic asset pack and I will be using the nice robot man from there. 06/19/17: It was much easier than I thought to switch between scenes. Killboxes just bring the player back to the beginning of the level, and a point at the end brings the player to the next level. Text is still not a thing
|
I want to create a simple game because I want to be able to finish it before the school year is up and just working with Unity is stretching my capabilities (even with guidance).
05/24/17 again: Last day I had to edit the script given in the Unity asset pack to bring it up to date, then I wrote the camera controller code as the one included followed along the Y axis but I wanted it only along the X axis :D (all of the code will be included later aH) 06/13/17: I need to bring my project home to separate some tilesets I downloaded. I still need to find a way to trigger events and pop-ups in game because I've been looking but haven't come across anything I wanted. Thinking I might have to downsize again because time constraints but I would prefer not to. I have located a helpful resource but it is in JavaScript so I am trying to redo it 06/15/17: my brain is gonna explode, text is dumb. The three "follow" scripts I have don't function how I want. Will be creating killboxes ASAP. I'll go back to trying to figure out how to get text to work once I've figured the thing out. "ne buzz pas, ne ring pas" - mr. whyte |
The resources i've collected so far
https://www.youtube.com/watch?v=vcFtoiWZ86w
https://www.youtube.com/watch?v=7wAjJBSQxys https://www.youtube.com/watch?v=_Tq97a_xnrs |
|