Day 8: Overview of Gameplay + transform.position glitch

10/11/2016

In my code:

if (toggleChasingPlayer) {
 
 direction = player.transform.position - transform.position;

// this levels out the bear and prevents it from sinking in the ground.

 direction = new Vector3 (direction.x, 0f, direction.z);
 direction.Normalize ();
 transform.Translate (direction * bearMoveRate * Time.deltaTime);

//moving towards the player at a certain rate


 if (Vector3.Distance (transform.position, player.transform.position) < 1f) {
 Application.LoadLevel (Application.loadedLevel);
 }

// if the bear touches player, the player will respawn/ restart the game

} else {
 direction = targetPosition - transform.position;
 direction.Normalize ();

Here’s what my bears look like with the current glitch:

Here you see that my bears are now successfully walking to a point, but after that they don’t have another anchor point to move towards, so that’s why they’re vibrating and moving erratically.

This recording was when I changed my code to the ‘MoveTowards’ function:

transform.position = Vector3.MoveTowards (transform.position, direction, bearMoveRate * Time.deltaTime);

before, my code was:

 transform.Translate (direction * bearMoveRate * Time.deltaTime);

I don’t have a solution yet for this glitch, but I was encouraged to look past my glitchy bears and develop the rest of the game.

So moving onward… what is the scope  of the game?

  1. One sentence game design concept pitch
    • Hot Pockets is a survival game where you have hotdogs to throw at bears while you try and survive the night
  2. Core design mechanics? Core feature?
    • You shoot hotdogs at bears try to survive the night
    • Core feature: Implement VR; will be running on cardboard SDK
    • Gameplay: get bears to walk idly before it detects the player, throw hotdogs to make bear go away
    • ‘safe zone’ of getting to a point in the forest to advance to next level

3. Content progression ‘story arc description’:

  1. Current content:
  • Bears now disappear when hit by hotdog
  • Hot dog shooter works

2. Planned expansions/ overview of game:

  • Implement VR aspect to the game

<cue intro scene; player gets kicked out into the forest>

I click play. It plays an intro scene. My friends suck! I get kicked out into the forest. I spot the hot dogs in the kitchen and grab them!
(consider knockable over hot dog surfaces)
after you grab the hotdogs, your friends chase you out.

  • Level 0- Countdown timer begins, setting: kitchen. Player grabs hotdogs in 15 seconds before transitioning to animation scene where your friends kick you out to the forest.
    (transitions to Level 1 after animation scene)
  • Level 1 – 12AM -2AM
    •   (bears are idly walking around, sees player then chases)
    • scene: dark skies
  • Level 2 – 2AM -4 AM
    • More bears, differentiate enemyBear type:
    • fat bears are slow and jiggly and can roll towards player,  introduce tall skinny bear that walks  like QWOP towards player;
    • scene: still somewhat dark, somewhat like twilight zone
  • Level 3 – 4AM -6 AM
    • Introduce other types of enemyBear to increase difficulty: Aerial bear
    • scene: dawn, brighter sunrise lighting

If you finish Level 3, you win the game because you survived the night

<cue win scene// gets back into house>

I have a long ways to go; just trying to make Level 1 playable before going into any of the other levels and complexity/ enemyBear behavior.

Feel free to reach out to me on twitter, I’m always happy to chat.

Advertisements

Day 7: Glitch- Making bears move

10/10/2016

Challenge: spawnCheck will check the spawn locations for a bear, and randomize where the bears will spawn, but now we want to also make the bears move idly.

Bear falling from a spawn point in the sky, and bears multiplying.

Bears now spawn randomly, but now theres an error when one of the hotdogs hit a bear, it doesn’t bounce off, instead it slides slowly down while the bear multiplies and freaks out.

Some of the bears behave normally, and the hotdog bounces off the bear when shot. Not sure if it’s the location of the bear, that certain bear’s physics, or if it’s the hotdog bullet physics.

I need to write a hotdog disappear script  so that the gameObject doesn’t exist after it’s been shot,  and I also need to write the bear moves code so that the bears can move idly in the game.

Playing around with both ‘vector3 moveTowards’, and ‘transform.translate’

Now encountering error where bears are shaking .

Screen Shot 2016-10-07 at 9.19.51 PM.png

Another fun glitch encountered when trying to run my game \( @u@ )/

Not sure how to fix my bears. Will continue to work through this glitch.

Feel free to reach out to me on twitter, I’m always happy to chat.

Day 6: Refining spawning bears

10/9/2016

Refining how the bears spawn.

Challenge to implement:
When the game starts, the game will generate 5 bears, if there’s only x amount of bears, it will generate until it reaches 5. It randomizes spawn location for each bear.

Set a public variable to set how many bears I want on the map

public int amountThings = 5; 

If the amount of bears on the map is less than 5, it will spawn a bear. It will try to figure out a good place to put the bear in spawnBear() function.

void Update() {
if (bears.Count < 5)
 {
 spawnBear(); 
 }
 }

public List <GameObject> GetBearsList (){
return bears;
}

‘spawnCheck’ will verify if a bear has spawned in the location. If there is a bear in the location, it will spawn elsewhere in one of the 5 spawn locations.

 bool spawnCheck(Transform loc) {
 foreach (GameObject bear in bears) {
 if (loc.position == bear.transform.position) {
 return true; 
 } 
 }
 return false;
 }

It’s so easy to get caught up in the details of how to make the bears behave, spawn, and interact with the player in the game. I didn’t realize how much time would be spent on making the bear just behave the way I want it to in the game.

work tired glasses cat school

Next on my task list:

  • make the bears walk idly around so they don’t stack when spawning
  • learn scene transitions/ animations to make the game feel more natural
  • introduce hotdogs/ opening scene to grab hotdogs; think through the mechanics of how this should work

Feel free to reach out to me on twitter, I’m always happy to chat.

 

Day 5: Glitch- Bears have trouble following player

10/7/2016

Sharing a glitch that started to happen to my bears when I made the bear collider from capsule collider into cube collider.

Floating bears, once they detect me, they come towards me and move up in y-axis. Spoooooky. The red ball thing you see that comes towards me is a leftover bear prototype I was using before importing my bear prefab.

Realized that I needed to switch back the collider. Cube colliders don’t behave well with these bears.

New glitch: Now bears behave weird / have trouble following player / doesn’t restart game when player touches bear. 

arrested development michael cera george michael bluth tired depressed

Fixed it by adding

direction.Normalize();

Because this code:

transform.Translate( direction * bearMoveRate * Time.deltaTime);

Moves the bears towards the player at a certain rate. The bear would move fast towards the player and then slow down as it reaches the player.

Now once I change the colliders, and add the ‘.Normailze();’ code, the bears behave normally now.

Next on my task list:

  • make the bears walk idly around so they don’t stack when spawning
  • learn scene transitions/ animations to make the game feel more natural
  • introduce hotdogs/ opening scene to grab hotdogs; think through the mechanics of how this should work

Feel free to reach out to me on twitter, I’m always happy to chat.

Day 4: Make the bears disappear

10/6/2016

Working on: Bear needs a script that has ‘OnTriggerEnter’ to say if this thing is a hotdog then (action to leave).

homer simpson the simpsons memes bush disappear

I created a new script titled ‘HotdogCollision’. What this script does is to make the trigger collision on the bear, and attach a rigid body component to the bear. We want to alert the bear that the hotdog hit them, so we need to set the bullet to ‘isTrigger’ and put a collider on the bear.

void OnTriggerEnter(Collider other)
 {

//bear is looking for hotdogs that hit it, and then destroys itself.

 if (other.gameObject.tag == "dog") 
 { 
 float delay = .2f; 
 Debug.Log (this.gameObject.name); //logs the bears name

//plays the audio clip where the bear is at

AudioSource.PlayClipAtPoint(this.gameObject.GetComponent<AudioSource>().clip, transform.position);

// reversing velocity (rigidbody off the hotdog and getting velocity of that and reverses it

other.gameObject.GetComponent<Rigidbody>().velocity = -(.3f)*other.gameObject.GetComponent<Rigidbody>().velocity;

//finds game obj spawner, gets bearSpawn script and gets the function ‘GetBearsList’

GameObject.Find("Spawner").GetComponent<bearSpawn>().GetBearsList().Remove(this.gameObject);

//it will destroy the bear in 3 seconds.

 Destroy(this.gameObject, delay); 

//removing the obj from list and destroying it when it gets hit

With one thing fixed, now there’s another issue that comes up:

  • We can make the bear disappear when it’s hit by a hotdog, but now we have a bunch of hotdog gameObjects existing in the game after they’ve been shot. We need to delete them from the game.

    video mrw dad destroy nations

Yep, another thing to add to the never ending task-list:

  • make the bears walk idly around so they don’t stack when spawning
  • learn scene transitions/ animations to make the game feel more natural
  • introduce hotdogs/ opening scene to grab hotdogs; think through the mechanics of how this should work

 

Feel free to reach out to me on twitter, I’m always happy to chat.

Day 3: Respawn bears + Hotdog shooter

10/4/2016

To Do:

  • Respawn the bear
  • Create hotdog shooter

 

Respawning bears

Sources I looked at for respawning enemies:

After some multiple Google searches & viewing tutorials, I referenced this Unity Spawn tutorial to make my bears respawn.

Pros: quick and dirty way to reference spawn locations, while also indicating which prefab to respawn.

Cons: This is hard-coded, which makes it difficult to have flexibility in code for later adjustments. (which was revised and addressed a few days later when I wanted more control of when and where the bears spawn)

Creating the hotdog Shooter 

  1. Create hotdog for ammo the player must be able to throw hotdog
  2. Add collider to hotdog prefab, and mark bear collider as trigger
  3. Bear needs a script that has ‘ontriggerenter’ to say if this thing is a hotdog then (action to leave)

I made the hotdog a prefab, called it ‘bulletPrefab’, and added a capsule collider to the gameObject hotdog shooter and checked ‘isTrigger’. We need the capsule collider to be ‘isTrigger’, because we want the gameObject bear to disappear when the hotdog hits the bear.

You need to declare objects in the game as ‘gameObject’ to be able to instantiate the object in the game.

Finished attaching hotdog as a gun (attached to FPSController)

Here’s my components attached to my FPS:

screen-shot-2016-10-12-at-3-17-29-pm

 

Part of the code in bulletPrefab:

// Use this for initialization

void Start () {

// You need to parent a game object called bulletSpawn to the player where you want bullets to appear

bulletSpawn = transform.Find ("hotdogSpawn");

//loops through all children transforms of the game object

 foreach (Transform child in transform) { 
 if (child.gameObject.tag == "dog")
 hotdogToThrow = child.gameObject; 
 }
 }

 

 

Screen Shot 2016-10-04 at 8.36.40 PM.png

Here you can see my bears are respawning at the location, and my hotdog shooter that’s attached to FPSController.

As you can see from the picture, some problems I need to address:

  • bears are respawning at the same location, but right now the bears don’t move idly unless they spot the player- which is why they’re stacked like pancakes.
  • once I can get the bears to walk around idly, I need to add a time delay so they don’t respawn too rapidly in the same location.

Next on my task list:

  • make the bears dissapear from scene once the hotdog bullet hits them
  • make the bears walk idly around so they don’t stack when spawning
  • learn scene transitions/ animations to make the game feel more natural
  • introduce hotdogs/ opening scene to grab hotdogs; think through the mechanics of how this should work

I didn’t realize all the extra parameters  to consider when respawning bears- a little worried about whether or not I’d get to scene transitions, animations/ rigging, and the intro scene. (・_・; )

Feel free to reach out to me on twitter, I’m always happy to chat.

Day 2: Made some trees and reset the game

From the previous list of things I’d like to implement in the game:

  • learn blender so I can create customized low-poly assets
  • once the bear touches player, it resets the game
  • respawn the bear
  • learn scene transitions/ animations to make the game feel more natural

I decided to start learning blender to make some low-poly trees for my environment. There’s a bunch of great ~free~ assets from 3Dwarehouse, and the asset store in Unity- but charmed by Julian Glander‘s 3D models – I wanted to get my feet wet in blender.

My current Unity environment looks pretty awful – and I just wanted to put some sweet lil’ trees to feel a bit better about it. I found  Pig Art’s tutorial on low poly forest to be immensely helpful. And also working on a Macbook w/ no mouse is pretty much like being on Cutthroat Kitchen.

635960130537231042-586871242_ck3.png

Lesson learned: having mouse when trying to use blender is important. Big thanks to Ryan who helped me with my 100x questions troubleshooting blender using the trackpad.

After 2 hours, I finally made some goddam trees.  CtttKRKUIAATLTa.jpgFirst baby trees in blender

After creating the assets in blender, I saved them to my assets folder and import them into my game. Realized that I messed up the positioning of my trees, went back in blender to reposition, and reimported it back into Unity.

It was fun playing around in Blender, and now that I scraped the surface of the program- I realized that I needed to refocus and get the mechanics of how I wanted the bear to behave.

To make my game a reality- I realized that I can’t focus on the UI and making things look pretty- it needs to work first. Understanding how to build the mechanics of how to make the bear work would a large amount of my time.

d6a1143f571184db25f94613edd43b40af6d3a629221aba00d9efdcfef5efd84.jpg

After making some sick trees,  I moved onto resetting the game once the bear touches the player.

I was getting an error using this script:

using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; public class BearCollision : MonoBehaviour {             void OnTriggerEnter (Collider other)             {             Debug.Log (other.gameObject.name);             SceneManager.LoadScene(level1);          }             }

What would happen was that my game would run, when I touched the bear, it would keep trying to load level1, but be caught in an infinite loop.

I asked Alex for help in troubleshooting this,  and instead we used:

if (Vector3.Distance (transform.position, player.transform.position) < 5f){                 Application.LoadLevel (Application.loadedLevel);             }

 

Next on my task list:

  • respawn the bear
  • learn scene transitions/ animations to make the game feel more natural
  • introduce hotdogs/ opening scene to grab hotdogs; think through the mechanics of how this should work

Feel free to reach out to me on twitter, I’m always happy to chat.