Jump to content
  • Advertisement

sidbhati32

Member
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

102 Neutral

About sidbhati32

  • Rank
    Member

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. sidbhati32

    C++ Game Asteroid

    Yeah it is. Kind of an assignment or a test you can say. But no problem. You can give me hints for doing it either? It will land me a job, that's what I want to say.
  2. sidbhati32

    C++ Game Asteroid

    Hey Alvaro. Thanks for going through the code but this is a test that I have got. I am supposed to find the bugs in this code and something is forcing the build to crash. But I'll honestly let them know a more optimized code for the given. Anyways the main issue is the bug. I have already fixed a few but I can't know what is causing this game to crash Thanks
  3. sidbhati32

    C++ Game Asteroid

    [ #include "Game.h" #include "System.h" #include "OrthoCamera.h" #include "Background.h" #include "Ship.h" #include "Asteroid.h" #include "Explosion.h" #include "Keyboard.h" #include "Random.h" #include "Maths.h" #include "Bullet.h" #include "Collision.h" #include <algorithm> Game::Game() : camera_(0), background_(0), player_(0), collision_(0) { camera_ = new OrthoCamera(); camera_->SetPosition(D3DXVECTOR3(0.0f, 0.0f, 0.0f)); camera_->SetFrustum(800.0f, 600.0f, -100.0f, 100.0f); background_ = new Background(800.0f, 600.0f); collision_ = new Collision(); } Game::~Game() { delete camera_; delete background_; delete player_; DeleteBullet(); DeleteAllAsteroids(); DeleteAllExplosions(); delete collision_; } void Game::Update(System *system) { UpdatePlayer(system); UpdateAsteroids(system); UpdateBullet(system); UpdateCollisions(); } void Game::RenderBackgroundOnly(Graphics *graphics) { camera_->SetAsView(graphics); background_->Render(graphics); } void Game::RenderEverything(Graphics *graphics) { camera_->SetAsView(graphics); background_->Render(graphics); if (player_) { player_->Render(graphics); } for (AsteroidList::const_iterator asteroidIt = asteroids_.begin(), end = asteroids_.end(); asteroidIt != end; ++asteroidIt) { (*asteroidIt)->Render(graphics); } if (bullet_) //**TODO: Candidate for crash { bullet_->Render(graphics); } for (ExplosionList::const_iterator explosionIt = explosions_.begin(), end = explosions_.end(); explosionIt != end; ++explosionIt) { (*explosionIt)->Render(graphics); } } void Game::InitialiseLevel(int numAsteroids) { DeleteAllAsteroids(); DeleteAllExplosions(); SpawnPlayer(); SpawnAsteroids(numAsteroids); } bool Game::IsLevelComplete() const { return (asteroids_.empty() && explosions_.empty()); } bool Game::IsGameOver() const { return (player_ == 0 && explosions_.empty()); } void Game::DoCollision(GameEntity *a, GameEntity *b) { Ship *player = static_cast<Ship *>(a == player_ ? a : (b == player_ ? b : 0)); Bullet *bullet = static_cast<Bullet *>(a == bullet_ ? a : (b == bullet_ ? b : 0)); Asteroid *asteroid = static_cast<Asteroid *>(IsAsteroid(a) ? a : (IsAsteroid(b) ? b : 0)); if (player && asteroid) { AsteroidHit(asteroid); DeletePlayer(); } if (bullet && asteroid) { AsteroidHit(asteroid); DeleteBullet(); } } void Game::SpawnPlayer() { DeletePlayer(); player_ = new Ship(); player_->EnableCollisions(collision_, 10.0f); } void Game::DeletePlayer() { delete player_; player_ = 0; } void Game::UpdatePlayer(System *system) { if (player_ == 0) return; Keyboard *keyboard = system->GetKeyboard(); float acceleration = 0.0f; if (keyboard->IsKeyHeld(VK_UP) || keyboard->IsKeyHeld('W')) { acceleration = 1.0f; } else if (keyboard->IsKeyHeld(VK_DOWN) || keyboard->IsKeyHeld('S')) { acceleration = -1.0f; } float rotation = 0.0f; if (keyboard->IsKeyHeld(VK_RIGHT) || keyboard->IsKeyHeld('D')) { rotation = -1.0f; } else if (keyboard->IsKeyHeld(VK_LEFT) || keyboard->IsKeyHeld('A')) { rotation = 1.0f; } player_->SetControlInput(acceleration, rotation); player_->Update(system); WrapEntity(player_); if (keyboard->IsKeyPressed(VK_SPACE)) { D3DXVECTOR3 playerForward = player_->GetForwardVector(); D3DXVECTOR3 bulletPosition = player_->GetPosition() + playerForward * 10.0f; SpawnBullet(bulletPosition, playerForward); } } void Game::UpdateAsteroids(System *system) { for (AsteroidList::const_iterator asteroidIt = asteroids_.begin(), end = asteroids_.end(); asteroidIt != end; ++asteroidIt) { (*asteroidIt)->Update(system); WrapEntity(*asteroidIt); } } void Game::UpdateBullet(System *system) { if (bullet_) { bullet_->Update(system); WrapEntity(bullet_); } } void Game::WrapEntity(GameEntity *entity) const { D3DXVECTOR3 entityPosition = entity->GetPosition(); entityPosition.x = Maths::WrapModulo(entityPosition.x, -400.0f, 400.0f); entityPosition.y = Maths::WrapModulo(entityPosition.y, -300.0f, 300.0f); entity->SetPosition(entityPosition); } void Game::DeleteAllAsteroids() { for (AsteroidList::const_iterator asteroidIt = asteroids_.begin(), end = asteroids_.end(); asteroidIt != end; ++asteroidIt) { delete (*asteroidIt); } asteroids_.clear(); } void Game::DeleteAllExplosions() { for (ExplosionList::const_iterator explosionIt = explosions_.begin(), end = explosions_.end(); explosionIt != end; ++explosionIt) { delete (*explosionIt); } explosions_.clear(); } void Game::SpawnBullet(const D3DXVECTOR3 &position, const D3DXVECTOR3 &direction) { DeleteBullet(); bullet_ = new Bullet(position, direction); bullet_->EnableCollisions(collision_, 3.0f); } void Game::DeleteBullet() { delete bullet_; bullet_ = 0; } void Game::SpawnAsteroids(int numAsteroids) { float halfWidth = 800.0f * 0.5f; float halfHeight = 600.0f * 0.5f; for (int i = 0; i < numAsteroids; i++) { float x = Random::GetFloat(-halfWidth, halfWidth); float y = Random::GetFloat(-halfHeight, halfHeight); D3DXVECTOR3 position = D3DXVECTOR3(x, y, 0.0f); SpawnAsteroidAt(position, 3); } } void Game::SpawnAsteroidAt(const D3DXVECTOR3 &position, int size) { const float MAX_ASTEROID_SPEED = 1.0f; float angle = Random::GetFloat(Maths::TWO_PI); D3DXMATRIX randomRotation; D3DXMatrixRotationZ(&randomRotation, angle); D3DXVECTOR3 velocity = D3DXVECTOR3(0.0f, Random::GetFloat(MAX_ASTEROID_SPEED), 0.0f); D3DXVec3TransformNormal(&velocity, &velocity, &randomRotation); Asteroid *asteroid = new Asteroid(position, velocity, size); asteroid->EnableCollisions(collision_, size * 5.0f); asteroids_.push_back(asteroid); } bool Game::IsAsteroid(GameEntity *entity) const { return (std::find(asteroids_.begin(), asteroids_.end(), entity) != asteroids_.end()); } void Game::AsteroidHit(Asteroid *asteroid) { int oldSize = asteroid->GetSize(); if (oldSize > 1) { int smallerSize = oldSize -1; D3DXVECTOR3 position = asteroid->GetPosition(); SpawnAsteroidAt(position, smallerSize); SpawnAsteroidAt(position, smallerSize); } DeleteAsteroid(asteroid); } void Game::DeleteAsteroid(Asteroid *asteroid) { asteroids_.remove(asteroid); delete asteroid; } void Game::UpdateCollisions() { collision_->DoCollisions(this); } ] this the code of Game.cpp #include "Bullet.h" #include "Graphics.h" Bullet::Bullet(const D3DXVECTOR3 &position, const D3DXVECTOR3 &direction) { const float BULLET_SPEED = 4.0f; SetPosition(position); D3DXVECTOR3 normalisedDirection; D3DXVec3Normalize(&normalisedDirection, &direction); velocity_ = normalisedDirection * BULLET_SPEED; } void Bullet::Update(System *system) { D3DXVECTOR3 position = GetPosition(); D3DXVec3Add(&position, &position, &velocity_); SetPosition(position); } void Bullet::Render(Graphics *graphics) const { const float RADIUS = 3.0f; struct DummyVert { float x, y, z; D3DCOLOR diffuse; }; DummyVert square[5] = { {-RADIUS, -RADIUS, 0.0f, 0xffffffff}, {-RADIUS, RADIUS, 0.0f, 0xffffffff}, { RADIUS, RADIUS, 0.0f, 0xffffffff}, { RADIUS, -RADIUS, 0.0f, 0xffffffff}, {-RADIUS, -RADIUS, 0.0f, 0xffffffff}, }; D3DXVECTOR3 position = GetPosition(); D3DXMATRIX translationMatrix; D3DXMatrixTranslation(&translationMatrix, position.x, position.y, position.z); D3DXMATRIX identityMatrix; D3DXMatrixIdentity(&identityMatrix); DWORD dummyFvf = D3DFVF_XYZ | D3DFVF_DIFFUSE; graphics->SetVertexFormat(dummyFvf); graphics->DisableLighting(); graphics->SetModelMatrix(&translationMatrix); graphics->DrawImmediate(D3DPT_LINESTRIP, 4, &square[0], sizeof(square[0])); graphics->SetModelMatrix(&identityMatrix); graphics->EnableLighting(); } this is of Bullet.cpp #include "Bullet.h" #include "Graphics.h" Bullet::Bullet(const D3DXVECTOR3 &position, const D3DXVECTOR3 &direction) { const float BULLET_SPEED = 4.0f; SetPosition(position); D3DXVECTOR3 normalisedDirection; D3DXVec3Normalize(&normalisedDirection, &direction); velocity_ = normalisedDirection * BULLET_SPEED; } void Bullet::Update(System *system) { D3DXVECTOR3 position = GetPosition(); D3DXVec3Add(&position, &position, &velocity_); SetPosition(position); } void Bullet::Render(Graphics *graphics) const { const float RADIUS = 3.0f; struct DummyVert { float x, y, z; D3DCOLOR diffuse; }; DummyVert square[5] = { {-RADIUS, -RADIUS, 0.0f, 0xffffffff}, {-RADIUS, RADIUS, 0.0f, 0xffffffff}, { RADIUS, RADIUS, 0.0f, 0xffffffff}, { RADIUS, -RADIUS, 0.0f, 0xffffffff}, {-RADIUS, -RADIUS, 0.0f, 0xffffffff}, }; D3DXVECTOR3 position = GetPosition(); D3DXMATRIX translationMatrix; D3DXMatrixTranslation(&translationMatrix, position.x, position.y, position.z); D3DXMATRIX identityMatrix; D3DXMatrixIdentity(&identityMatrix); DWORD dummyFvf = D3DFVF_XYZ | D3DFVF_DIFFUSE; graphics->SetVertexFormat(dummyFvf); graphics->DisableLighting(); graphics->SetModelMatrix(&translationMatrix); graphics->DrawImmediate(D3DPT_LINESTRIP, 4, &square[0], sizeof(square[0])); graphics->SetModelMatrix(&identityMatrix); graphics->EnableLighting(); } Bullet.cpp #include "Game.h" #include "System.h" #include "OrthoCamera.h" #include "Background.h" #include "Ship.h" #include "Asteroid.h" #include "Explosion.h" #include "Keyboard.h" #include "Random.h" #include "Maths.h" #include "Bullet.h" #include "Collision.h" #include <algorithm> Game::Game() : camera_(0), background_(0), player_(0), collision_(0) { camera_ = new OrthoCamera(); camera_->SetPosition(D3DXVECTOR3(0.0f, 0.0f, 0.0f)); camera_->SetFrustum(800.0f, 600.0f, -100.0f, 100.0f); background_ = new Background(800.0f, 600.0f); collision_ = new Collision(); } Game::~Game() { delete camera_; delete background_; delete player_; DeleteBullet(); DeleteAllAsteroids(); DeleteAllExplosions(); delete collision_; } void Game::Update(System *system) { UpdatePlayer(system); UpdateAsteroids(system); UpdateBullet(system); UpdateCollisions(); } void Game::RenderBackgroundOnly(Graphics *graphics) { camera_->SetAsView(graphics); background_->Render(graphics); } void Game::RenderEverything(Graphics *graphics) { camera_->SetAsView(graphics); background_->Render(graphics); if (player_) { player_->Render(graphics); } for (AsteroidList::const_iterator asteroidIt = asteroids_.begin(), end = asteroids_.end(); asteroidIt != end; ++asteroidIt) { (*asteroidIt)->Render(graphics); } if (bullet_) //**TODO: Candidate for crash { bullet_->Render(graphics); } for (ExplosionList::const_iterator explosionIt = explosions_.begin(), end = explosions_.end(); explosionIt != end; ++explosionIt) { (*explosionIt)->Render(graphics); } } void Game::InitialiseLevel(int numAsteroids) { DeleteAllAsteroids(); DeleteAllExplosions(); SpawnPlayer(); SpawnAsteroids(numAsteroids); } bool Game::IsLevelComplete() const { return (asteroids_.empty() && explosions_.empty()); } bool Game::IsGameOver() const { return (player_ == 0 && explosions_.empty()); } void Game::DoCollision(GameEntity *a, GameEntity *b) { Ship *player = static_cast<Ship *>(a == player_ ? a : (b == player_ ? b : 0)); Bullet *bullet = static_cast<Bullet *>(a == bullet_ ? a : (b == bullet_ ? b : 0)); Asteroid *asteroid = static_cast<Asteroid *>(IsAsteroid(a) ? a : (IsAsteroid(b) ? b : 0)); if (player && asteroid) { AsteroidHit(asteroid); DeletePlayer(); } if (bullet && asteroid) { AsteroidHit(asteroid); DeleteBullet(); } } void Game::SpawnPlayer() { DeletePlayer(); player_ = new Ship(); player_->EnableCollisions(collision_, 10.0f); } void Game::DeletePlayer() { delete player_; player_ = 0; } void Game::UpdatePlayer(System *system) { if (player_ == 0) return; Keyboard *keyboard = system->GetKeyboard(); float acceleration = 0.0f; if (keyboard->IsKeyHeld(VK_UP) || keyboard->IsKeyHeld('W')) { acceleration = 1.0f; } else if (keyboard->IsKeyHeld(VK_DOWN) || keyboard->IsKeyHeld('S')) { acceleration = -1.0f; } float rotation = 0.0f; if (keyboard->IsKeyHeld(VK_RIGHT) || keyboard->IsKeyHeld('D')) { rotation = -1.0f; } else if (keyboard->IsKeyHeld(VK_LEFT) || keyboard->IsKeyHeld('A')) { rotation = 1.0f; } player_->SetControlInput(acceleration, rotation); player_->Update(system); WrapEntity(player_); if (keyboard->IsKeyPressed(VK_SPACE)) { D3DXVECTOR3 playerForward = player_->GetForwardVector(); D3DXVECTOR3 bulletPosition = player_->GetPosition() + playerForward * 10.0f; SpawnBullet(bulletPosition, playerForward); } } void Game::UpdateAsteroids(System *system) { for (AsteroidList::const_iterator asteroidIt = asteroids_.begin(), end = asteroids_.end(); asteroidIt != end; ++asteroidIt) { (*asteroidIt)->Update(system); WrapEntity(*asteroidIt); } } void Game::UpdateBullet(System *system) { if (bullet_) { bullet_->Update(system); WrapEntity(bullet_); } } void Game::WrapEntity(GameEntity *entity) const { D3DXVECTOR3 entityPosition = entity->GetPosition(); entityPosition.x = Maths::WrapModulo(entityPosition.x, -400.0f, 400.0f); entityPosition.y = Maths::WrapModulo(entityPosition.y, -300.0f, 300.0f); entity->SetPosition(entityPosition); } void Game::DeleteAllAsteroids() { for (AsteroidList::const_iterator asteroidIt = asteroids_.begin(), end = asteroids_.end(); asteroidIt != end; ++asteroidIt) { delete (*asteroidIt); } asteroids_.clear(); } void Game::DeleteAllExplosions() { for (ExplosionList::const_iterator explosionIt = explosions_.begin(), end = explosions_.end(); explosionIt != end; ++explosionIt) { delete (*explosionIt); } explosions_.clear(); } void Game::SpawnBullet(const D3DXVECTOR3 &position, const D3DXVECTOR3 &direction) { DeleteBullet(); bullet_ = new Bullet(position, direction); bullet_->EnableCollisions(collision_, 3.0f); } void Game::DeleteBullet() { delete bullet_; bullet_ = 0; } void Game::SpawnAsteroids(int numAsteroids) { float halfWidth = 800.0f * 0.5f; float halfHeight = 600.0f * 0.5f; for (int i = 0; i < numAsteroids; i++) { float x = Random::GetFloat(-halfWidth, halfWidth); float y = Random::GetFloat(-halfHeight, halfHeight); D3DXVECTOR3 position = D3DXVECTOR3(x, y, 0.0f); SpawnAsteroidAt(position, 3); } } void Game::SpawnAsteroidAt(const D3DXVECTOR3 &position, int size) { const float MAX_ASTEROID_SPEED = 1.0f; float angle = Random::GetFloat(Maths::TWO_PI); D3DXMATRIX randomRotation; D3DXMatrixRotationZ(&randomRotation, angle); D3DXVECTOR3 velocity = D3DXVECTOR3(0.0f, Random::GetFloat(MAX_ASTEROID_SPEED), 0.0f); D3DXVec3TransformNormal(&velocity, &velocity, &randomRotation); Asteroid *asteroid = new Asteroid(position, velocity, size); asteroid->EnableCollisions(collision_, size * 5.0f); asteroids_.push_back(asteroid); } bool Game::IsAsteroid(GameEntity *entity) const { return (std::find(asteroids_.begin(), asteroids_.end(), entity) != asteroids_.end()); } void Game::AsteroidHit(Asteroid *asteroid) { int oldSize = asteroid->GetSize(); if (oldSize > 1) { int smallerSize = oldSize -1; D3DXVECTOR3 position = asteroid->GetPosition(); SpawnAsteroidAt(position, smallerSize); SpawnAsteroidAt(position, smallerSize); } DeleteAsteroid(asteroid); } void Game::DeleteAsteroid(Asteroid *asteroid) { asteroids_.remove(asteroid); delete asteroid; } void Game::UpdateCollisions() { collision_->DoCollisions(this); } this is Game.cpp
  4. Hey guys, I am getting an exception when I run my code. It's an asteroid game and I am using VS2012 express for it. When I run my code I get this warning dialogue box and then it takes me to UpdateBullet function.
  5. Hello, I am using unity and I am confused on one part It's like I have three buttons out of which one has to be selected. If I have selected one of the three buttons during runtime and then I want to select the other button. How would Unity know that only one button has to be selected out of the three and unity has to disable the older selected button now? There must be some function to make unity know that it has to deselect the older option and select the newer one? I have attached a screen shot along with this. Thanks
  6. Okay, so I am making a character controller in Unity of a 3D model. it got two layers of animation - the base layer works perfectly fine but the 1st layer in which the character holds a flash light. The animation works fine until the arm starts behaving weirdly when the shoulder is rotated upside or downwards. I am attaching a video along with this https://drive.google.com/open?id=1hLFx3Szx4au4-2PZaAEa3d1f8kNmWMUH if someone knows how to do it then please let me know. It would be a great help I have used IK for this. Set the IK target to the torch but it still didn't work
  7. @Scouting Ninja Hey, Thanks for taking your time out to explain me this thing.
  8. 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

  9. @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.
  10. @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
  11. @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?
  12. 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
  13. 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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!