• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Cuber01

Members
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

121 Neutral

About Cuber01

  • Rank
    Newbie

Personal Information

  • Interests
    |programmer|
  1. Hello I am working in unity with c#. I am working on a 2D platformer for mobile. The way I currently have it setup is one joystick that moves the charatcer makes the charatcer arm rotate and make the charatcer shoot the gun when pressed. Which all workd fine. But the problem I am having is the bullets from the gun are not going in the correct direction. Currently the bullets go to the rigtht no matter where I point the gun. I have tried in the raycats to use transform.right and transform.forward. All end up with the same result. the firepoint for the gun is an empty game object and the firepoint in the script is an tranfrom. I tried changing it to an GameObject in the script but I got the same results. If someone could please help it would be grealty appreciated!!! Here is the shoot function with the raycast. public void Shoot ()     {         Vector3 firePointPosition = new Vector3 (firePoint.position.x, firePoint.position.y, 0f);         RaycastHit2D hit = Physics2D.Raycast (firePointPosition, firePoint.transform.right, 100, whatToHit, 0f);           Debug.DrawRay(firePointPosition, firePoint.transform.right * 100);         if (hit.collider != null)         {             Debug.DrawLine(firePointPosition, hit.point, Color.red);             Enemy enemy = hit.collider.GetComponent<Enemy>();             if (enemy != null)             {                 enemy.DamageEnemy(Damage);                 //Debug.Log("We hit " + hit.collider.name + "and did " + Damage + "damage");             }         }           if (Time.time >= timeToSpawnEffect)         {             Vector3 hitPos;             Vector3 hitNormal;               if (hit.collider == null)             {                 hitPos = (firePointPosition) * 30;                 hitNormal = new Vector3(9999, 9999, 9999);             }             else             {                 hitPos = hit.point;                 hitNormal = hit.normal;             }                                             Effect(hitPos, hitNormal);             timeToSpawnEffect = Time.time + 1 / effectSpawnRate;         }     }   And the effect method    void Effect (Vector3 hitPos, Vector3 hitNormal)     {         Transform trail = Instantiate (BulletTrailPrefab, firePoint.position, firePoint.rotation) as Transform;         LineRenderer Lr = trail.GetComponent<LineRenderer>();           if (Lr != null)         {             Lr.SetPosition(0, firePoint.position);             Lr.SetPosition(1, hitPos);           }           Destroy(trail.gameObject, 0.04f);           if (hitNormal != new Vector3(9999,9999,9999))         {             Transform hitParticle = Instantiate(HitPrefab, hitPos, Quaternion.FromToRotation (Vector3.right, hitNormal))as Transform;             Destroy(hitParticle.gameObject, 1f);         }           Transform clone = Instantiate (MuzzleFlashPrefab, firePoint.position, firePoint.rotation) as Transform;         clone.parent = firePoint;         float size = Random.Range(0.6f, 0.9f);         clone.localScale = new Vector3 (size, size, size);         Destroy(clone.gameObject, 0.02f);           //Shake the Camera         camShake.Shake(camShakeAmt, camShakeLength);           //Play shoot sound         audioManger.PlaySound(weaponShootSound);     }  
  2. am working on a 2D platformer and i am tring to add mobile controls. What I want is for the joystick that moves the player (which works) to also wehn you touch the joystick for the player to shoot. I tried usuing cross platform Input Manger in replace of input but all it did was make it so notjing happend the player will still not shoot. If someone could help me out that would be great!!!! Here is the code in c# void Update ()     {         if (fireRate == 0)         {             if (CrossPlatformInputManager.GetButtonDown("Fire1"))                  {                 Shoot();                       }         }         else         {             if (CrossPlatformInputManager.GetButton ("Fire1") && Time.time > timeToFire)              {                 timeToFire = Time.time + 1 / fireRate;                 Shoot();             }         }     }   And the Shoot Method    void Shoot ()     {         Vector2 joyStickPosition = new Vector2(Camera.main.ScreenToWorldPoint(CrossPlatformInputManager.mousePosition).x, Camera.main.ScreenToWorldPoint(CrossPlatformInputManager.mousePosition).y);         Vector2 firePointPosition = new Vector2 (firePoint.position.x, firePoint.position.y);         RaycastHit2D hit = Physics2D.Raycast (firePointPosition, joyStickPosition-firePointPosition, 100, whatToHit);           Debug.DrawLine(firePointPosition, (joyStickPosition - firePointPosition)*100, Color.cyan);          if (hit.collider != null)         {             Debug.DrawLine(firePointPosition, hit.point, Color.red);             Enemy enemy = hit.collider.GetComponent<Enemy>();             if (enemy != null)             {                 enemy.DamageEnemy(Damage);                 //Debug.Log("We hit " + hit.collider.name + "and did " + Damage + "damage");             }         }  
  3. I am working on a 2D platformer and I am adding mobile controls. I am trying to get the player to shoot when you touch and move the joystick. I tried to change all of the Input to CrossPlatformInputManger but when I use the joystick nothing happens. Please any sugggestions will be helpful! Thanks!!!! Here is what is in the update method   void Update () {         if (fireRate == 0)         {             if (CrossPlatformInputManager.GetButtonDown("Fire1"))                  {                 Shoot();                       }         }         else         {             if (CrossPlatformInputManager.GetButton ("Fire1") && Time.time > timeToFire)              {                 timeToFire = Time.time + 1 / fireRate;                 Shoot();             }         }     }   and the Shoot Method   void Shoot ()     {         Vector2 joyStickPosition = new Vector2(Camera.main.ScreenToWorldPoint(CrossPlatformInputManager.mousePosition).x, Camera.main.ScreenToWorldPoint(CrossPlatformInputManager.mousePosition).y);         Vector2 firePointPosition = new Vector2 (firePoint.position.x, firePoint.position.y);         RaycastHit2D hit = Physics2D.Raycast (firePointPosition, joyStickPosition-firePointPosition, 100, whatToHit);           Debug.DrawLine(firePointPosition, (joyStickPosition - firePointPosition)*100, Color.cyan);          if (hit.collider != null)         {             Debug.DrawLine(firePointPosition, hit.point, Color.red);             Enemy enemy = hit.collider.GetComponent<Enemy>();             if (enemy != null)             {                 enemy.DamageEnemy(Damage);                 //Debug.Log("We hit " + hit.collider.name + "and did " + Damage + "damage");             }         } 0down votefavorite   I am working on a 2D platformer and I am adding mobile controls. I am trying to get the player to shoot when you touch and move the joystick. I tried to change all of the Input to CrossPlatformInputManger but when I use the joystick nothing happens. Please any sugggestions will be helpful! Thanks!!!! Here is what is in the update method void Update () { if (fireRate == 0) { if (CrossPlatformInputManager.GetButtonDown("Fire1")) { Shoot(); } } else { if (CrossPlatformInputManager.GetButton ("Fire1") && Time.time > timeToFire) { timeToFire = Time.time + 1 / fireRate; Shoot(); } } } And the Shoot method void Shoot () { Vector2 joyStickPosition = new Vector2(Camera.main.ScreenToWorldPoint(CrossPlatformInputManager.mousePosition).x, Camera.main.ScreenToWorldPoint(CrossPlatformInputManager.mousePosition).y); Vector2 firePointPosition = new Vector2 (firePoint.position.x, firePoint.position.y); RaycastHit2D hit = Physics2D.Raycast (firePointPosition, joyStickPosition-firePointPosition, 100, whatToHit); Debug.DrawLine(firePointPosition, (joyStickPosition - firePointPosition)*100, Color.cyan); if (hit.collider != null) { Debug.DrawLine(firePointPosition, hit.point, Color.red); Enemy enemy = hit.collider.GetComponent<Enemy>(); if (enemy != null) { enemy.DamageEnemy(Damage); //Debug.Log("We hit " + hit.collider.name + "and did " + Damage + "damage"); }
  4. Thanks for the respose I did get it to work but now I ran into another issue and I am wodering if you can help me?   The arm now rotates but the bullet trail that comes out of the gun to kill the enemies dosent follow the joystick.   I have tried to change the Input to CrossPlatformInputManger but all it does is stay in one place   here is the code that shoots    void Shoot ()     {         Vector2 mousePosition = new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint (Input.mousePosition).y);         Vector2 firePointPosition = new Vector2 (firePoint.position.x, firePoint.position.y);         RaycastHit2D hit = Physics2D.Raycast (firePointPosition, mousePosition-firePointPosition, 100, whatToHit);           Debug.DrawLine(firePointPosition, (mousePosition - firePointPosition)*100, Color.cyan);          if (hit.collider != null)         {             Debug.DrawLine(firePointPosition, hit.point, Color.red);             Enemy enemy = hit.collider.GetComponent<Enemy>();             if (enemy != null)             {                 enemy.DamageEnemy(Damage);             }         }
  5. I am making a 2D Platformer in unity using c#. I am working on adding mobile controls to the game. Right now I have one joystick that controls the player movement as well as rotating the arm to shoot the enemies that come from above Issues I am running into When I move the joystick to move the player the arm does rotate but the bullet trail that kills the enemies does not follow as well. What I have done I did import the CrossPlatformInput libary to the script. I tried to change the Input.mousePosition to CrossPlatformInputManger but all it did was stay in one place. Here is the weapon script with the shoot method void Shoot () { Vector2 mousePosition = new Vector2 (Camera.main.ScreenToWorldPoint (Input.mousePosition).x, Camera.main.ScreenToWorldPoint (Input.mousePosition).y); Vector2 firePointPosition = new Vector2 (firePoint.position.x, firePoint.position.y); RaycastHit2D hit = Physics2D.Raycast (firePointPosition, mousePosition-firePointPosition, 100, whatToHit); Debug.DrawLine(firePointPosition, (mousePosition – firePointPosition)*100, Color.cyan); if (hit.collider != null) { Debug.DrawLine(firePointPosition, hit.point, Color.red); Enemy enemy = hit.collider.GetComponent<Enemy>(); if (enemy != null) { enemy.DamageEnemy(Damage); } }
  6. Hello, I have been working on a 2D platformer and right now I have set up in a way that makes the arm follow the mouse cursor. I want to be able to have it so that when you move the joystick it moves the arm as well. Here is the arm rotation script using UnityEngine; using System.Collections; public class ArmRotation : MonoBehaviour { public int rotationOffset = 0; void Update () { Vector3 mousePos = Input.mousePosition; mousePos.z = 5.23f; Vector3 objectPos = Camera.main.WorldToScreenPoint(transform.position); mousePos.x = mousePos.x – objectPos.x; mousePos.y = mousePos.y – objectPos.y; float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle)); } }
  7. Hello,   I have been working on a 2D Platformer and I am at the point where I want to add mobile controls for the phone. I am new to unity so I need some help.   Here is what I have:      The basic gameplay is waves of aliens come from above and you have to shoot them. The aming is right now controlled by the mouse. The gun follows the mouse      basic movement is controlled with the arrow keys and space bar      I also have the Unity standard assets in my project as well Here is what I want:      I want to have 2 joysticks one that controls the movement of the player and one that controls the aming and shooting      For shooting I want to be already shooting when you place your finger on the joystick   If someone could please help me with it. Tell me what to add and stuff like that would be really appreciated!!   Here are some of my scripts:   PlayerController:            using System; using UnityEngine; using UnityStandardAssets.CrossPlatformInput;   namespace UnityStandardAssets._2D {     [RequireComponent(typeof (PlatformerCharacter2D))]     public class Platformer2DUserControl : MonoBehaviour     {         private PlatformerCharacter2D m_Character;         private bool m_Jump;             private void Awake()         {             m_Character = GetComponent<PlatformerCharacter2D>();         }             private void Update()         {             if (!m_Jump)             {                 // Read the jump input in Update so button presses aren't missed.                 m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");             }         }             private void FixedUpdate()         {             // Read the inputs.             bool crouch = Input.GetKey(KeyCode.LeftControl);             float h = CrossPlatformInputManager.GetAxis("Horizontal");             // Pass all parameters to the character control script.             m_Character.Move(h, crouch, m_Jump);             m_Jump = false;         }     } }   Character 2D script        using System; using UnityEngine;   namespace UnityStandardAssets._2D {     public class PlatformerCharacter2D : MonoBehaviour     {         [SerializeField] private float m_JumpForce = 400f;                  // Amount of force added when the player jumps.         [Range(0, 1)] [SerializeField] private float m_CrouchSpeed = .36f;  // Amount of maxSpeed applied to crouching movement. 1 = 100%         [SerializeField] private bool m_AirControl = false;                 // Whether or not a player can steer while jumping;         [SerializeField] private LayerMask m_WhatIsGround;                  // A mask determining what is ground to the character           [SerializeField]         string landingSoundName = "LandingFootsteps";           private Transform m_GroundCheck;    // A position marking where to check if the player is grounded.         const float k_GroundedRadius = .2f; // Radius of the overlap circle to determine if grounded         private bool m_Grounded;            // Whether or not the player is grounded.         private Transform m_CeilingCheck;   // A position marking where to check for ceilings         const float k_CeilingRadius = .01f; // Radius of the overlap circle to determine if the player can stand up         private Animator m_Anim;            // Reference to the player's animator component.         private Rigidbody2D m_Rigidbody2D;         private bool m_FacingRight = true;  // For determining which way the player is currently facing.           private Transform playerGraphics;          // reference to the graphics so we can chnage direction           AudioManger audioManger;           private void Awake()         {             // Setting up references.             m_GroundCheck = transform.Find("GroundCheck");             m_CeilingCheck = transform.Find("CeilingCheck");             m_Anim = GetComponent<Animator>();             m_Rigidbody2D = GetComponent<Rigidbody2D>();             playerGraphics = transform.FindChild("Graphics");             if (playerGraphics == null)             {                 Debug.LogError("Lets freak out! There is no 'Graphics' object as a child of the player");              }                     }           void Start ()         {             audioManger = AudioManger.instance;             if(audioManger == null)             {                 Debug.LogError("THIS IS WHY WE WRIGHT ERROR MESSAGES: No audioManger found.");             }         }           private void FixedUpdate()         {             bool wasGrounded = m_Grounded;                 m_Grounded = false;               // The player is grounded if a circlecast to the groundcheck position hits anything designated as ground             // This can be done using layers instead but Sample Assets will not overwrite your project settings.             Collider2D[] colliders = Physics2D.OverlapCircleAll(m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround);             for (int i = 0; i < colliders.Length; i++)             {                 if (colliders[i].gameObject != gameObject)                     m_Grounded = true;             }             m_Anim.SetBool("Ground", m_Grounded);               if (wasGrounded != m_Grounded && m_Grounded == true)             {                 audioManger.PlaySound(landingSoundName);             }               // Set the vertical animation             m_Anim.SetFloat("vSpeed", m_Rigidbody2D.velocity.y);         }           public void Move(float move, bool crouch, bool jump)           {             // If crouching, check to see if the character can stand up             if (!crouch && m_Anim.GetBool("Crouch"))             {                 // If the character has a ceiling preventing them from standing up, keep them crouching                 if (Physics2D.OverlapCircle(m_CeilingCheck.position, k_CeilingRadius, m_WhatIsGround))                 {                     crouch = true;                 }             }               // Set whether or not the character is crouching in the animator             m_Anim.SetBool("Crouch", crouch);               //only control the player if grounded or airControl is turned on             if (m_Grounded || m_AirControl)             {                 // Reduce the speed if crouching by the crouchSpeed multiplier                 move = (crouch ? move*m_CrouchSpeed : move);                   // The Speed animator parameter is set to the absolute value of the horizontal input.                 m_Anim.SetFloat("Speed", Mathf.Abs(move));                   // Move the character                 m_Rigidbody2D.velocity = new Vector2(move*PlayerStats.instance.movementSpeed, m_Rigidbody2D.velocity.y);                   // If the input is moving the player right and the player is facing left...                 if (move > 0 && !m_FacingRight)                 {                     // ... flip the player.                     Flip();                 }                     // Otherwise if the input is moving the player left and the player is facing right...                 else if (move < 0 && m_FacingRight)                 {                     // ... flip the player.                     Flip();                 }             }             // If the player should jump...             if (m_Grounded && jump && m_Anim.GetBool("Ground"))             {                 // Add a vertical force to the player.                 m_Grounded = false;                 m_Anim.SetBool("Ground", false);                 m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce));             }         }           private void Flip()         {             // Switch the way the player is labelled as facing.             m_FacingRight = !m_FacingRight;               // Multiply the player's x local scale by -1.             Vector3 theScale = playerGraphics.localScale;             theScale.x *= -1;             playerGraphics.localScale = theScale;         }     } }