sidbhati32

Members
  • Content count

    5
  • Joined

  • Last visited

Community Reputation

103 Neutral

About sidbhati32

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. How to Detect if I have touched the correct alphabet

    @Scouting Ninja Hey, Thanks for taking your time out to explain me this thing.
  2. I have randomly generated spheres having different alphabets and predefined words. 

    Presently, I cannot compare the alphabet in the sphere with the alphabets of the word. 

    Let me show you the code 

     

    For randomly generating different alphabets -

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;

    public class GenerateRandom : MonoBehaviour {

        private Text[] Circle;

        // Use this for initialization
        void Start () {

            Circle = GameObject.FindGameObjectWithTag ("Text").GetComponentsInChildren<Text> ();
            char[] S = "qwertyuiopasdfghjklzxcvbnm".ToCharArray ();


            for (int i = 0; i < 3; i++) {
                Circle .text = S [Random.Range (0, 25)].ToString ();


            }
        }    
        // Update is called once per frame
        void Update () {
            
        }
    }
     

     

     

    For Randomly generating a word -

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;

    public class RandomWord : MonoBehaviour {

        string[] Words = { "great", "stage", "peak", "street", "please" };

        private Text texter; 
        // Use this for initialization
        void Start () {
            texter = GameObject.FindGameObjectWithTag ("Sphere").GetComponent<Text>();
            texter.text =  Words[Random.Range (0, 4)].ToString();
        }
        
        // Update is called once per frame
        void Update () {
            
        }
    }
     

     

    For collision detection and checking the correct alphabet - 

     

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;

    public class Destroy : MonoBehaviour {


        private char[] Check;
        private string Me,You;

        // Use this for initialization
        void Start () {

            Me = GameObject.FindGameObjectWithTag ("Sphere").GetComponent<Text> ().ToString ();


        }
        
        // Update is called once per frame
        void Update () {
            

        }

        void OnCollisionEnter2D(Collision2D other)
        {
            
            int Length = Me.Length;

            Check = Me.ToCharArray ();

            Debug.Log ("Collision");

            if(GameObject.FindWithTag ("Background"))
            {
                You = other.gameObject.GetComponent<Text> ().ToString ();
                if(You != null)
                {
                    for(int i=0 ; i<Length; i++)
                    {
                        if (You == Check .ToString ())
                            Debug.Log ("Matched");

                    }
                }
            }

            Destroy (other.gameObject);

    }
    }

     

     

    Now I am getting the issue in the picture I have shared.

     

    When I double click the error, it redirects me to -

         You = other.gameObject.GetComponent<Text> ().ToString ();

     

    Looking forward to your help :) 

    Thanks 

    Untitled.png

  3. How to Detect if I have touched the correct alphabet

    @Scouting Ninja Sure Sir, I have to submit this by 21st, see if you can help me before the date else no problem. Thanks for the help If you can link me to any tutorial that will help me in my case, it would be a great help.
  4. How to Detect if I have touched the correct alphabet

    @Scouting Ninja @Cold.bo @Mike2343 I have progressed a bit with the project - I have randomly generated spheres having different alphabets and predefined words. Presently, I cannot compare the alphabet in the sphere with the alphabets of the word. Let me show you the code For randomly generating different alphabets - using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GenerateRandom : MonoBehaviour { private Text[] Circle; // Use this for initialization void Start () { Circle = GameObject.FindGameObjectWithTag ("Text").GetComponentsInChildren<Text> (); char[] S = "qwertyuiopasdfghjklzxcvbnm".ToCharArray (); for (int i = 0; i < 3; i++) { Circle .text = S [Random.Range (0, 25)].ToString (); } } // Update is called once per frame void Update () { } } For Randomly generating a word - using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class RandomWord : MonoBehaviour { string[] Words = { "great", "stage", "peak", "street", "please" }; private Text texter; // Use this for initialization void Start () { texter = GameObject.FindGameObjectWithTag ("Sphere").GetComponent<Text>(); texter.text = Words[Random.Range (0, 4)].ToString(); } // Update is called once per frame void Update () { } } For collision detection and checking the correct alphabet - using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Destroy : MonoBehaviour { private char[] Check; private string Me,You; // Use this for initialization void Start () { Me = GameObject.FindGameObjectWithTag ("Sphere").GetComponent<Text> ().ToString (); } // Update is called once per frame void Update () { } void OnCollisionEnter2D(Collision2D other) { int Length = Me.Length; Check = Me.ToCharArray (); Debug.Log ("Collision"); if(GameObject.FindWithTag ("Background")) { You = other.gameObject.GetComponent<Text> ().ToString (); if(You != null) { for(int i=0 ; i<Length; i++) { if (You == Check .ToString ()) Debug.Log ("Matched"); } } } Destroy (other.gameObject); } } Now I am getting the issue in the picture I have shared. When I double click the error, it redirects me to - You = other.gameObject.GetComponent<Text> ().ToString (); Looking forward to your help Thanks
  5. How to Detect if I have touched the correct alphabet

    @Scouting Ninja Yeah collision is not a problem. Suppose I have got a word "Random" and three spheres having different alphabets must fall down. At least one them should be from the word "Random". How am I supposed to link the word generated with the the alphabets falling down? Suppose "A","S","P" fall down and I interact with A then how would Unity know that A is a correct alphabet?
  6. I am working on a game in which we control a rectangular box at the bottom of the screen. Three sphere which has alphabets in it fall down. When the game starts, a word is generated from the predefined list of words(which I'll give) and we are supposed to touch the correct sphere having the alphabet based on that word. The question is how to detect if I have touched the correct sphere. secondly, if I have touched a correct sphere before and there is no recurrence of that alphabet in that word then during the second wave the game should not proceed if I touch the same alphabet again. Looking forward to your answers, i have to submit this project in a couple of days. please help! (Working on Unity 3D) Thanks
  7. Hello Sir,

     

    I hope you're good.

    So, I was basically planning to implement a simple 2d physics Game Engine in C++.

    I have read many articles related to it and I had no problem in grasping the concepts of physics and maths but when it comes to implementation i badly fail at it, although, i have made a couple of games on c++ like Arkanoid and Pong but both of them don't use real physics. I just need to multiply the velocity by -1 to respond to collision.

    It is further getting demotivating as no one around me can help me out in this.

    So, I am using SFML and I am first planning to do very basic i.e, making a circle bounce in a window with perfect elasticity and no gravity.

    I have covered topics of circle-rectangle collision detection etc. 

    I have covered collision response too but it's hard to implement in a program.

    What would you suggest me to do so I can build a simple physics simulation?

     

    Thank You