Hello Guest

Author Topic: Whack a Mole Tutorial - Moles not being whacked  (Read 3753 times)

WRECKER

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Whack a Mole Tutorial - Moles not being whacked
« on: July 28, 2013, 04:04:42 pm »
Hello,

I'm new to unity and 2d toolkit.

I'm working through the Whack a Mole Tutorial.

Everything seems to be fine except when I click on the moles nothing happens.

I've added some debug statements
Code: [Select]
void Update()
{
// Check to see if mouse has been clicked, and if so check to see if it has 'hit' any of the moles, and check which mole.
//if(Input.GetMouseButtonDown(0))
if(Input.GetButtonDown("Fire1"))
{
Debug.Log("Pressed left click.");

Ray ray = gameCam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit = new RaycastHit();

if(Physics.Raycast(ray, out hit))
{
Debug.Log("Inside If Physics.Raycast.")
..........
........
.....

I am seeing the debug statement for the mouse click but not the Physics.Raycast

I notice the main camera looks a little bit odd. The camera bounds do not seem to line up. However the "tk2d camera preview" looks good and the "camera preview" looks to only be seeing what the white camera bounds are seeing. 
My Scene looks like this:

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Whack a Mole Tutorial - Moles not being whacked
« Reply #1 on: July 28, 2013, 04:14:20 pm »
You're using the wrong version of 2D Toolkit.
The whack a mole tutorial is from the 2D Toolkit 2.1 documentation.

Also, you should download the final .unitypackages from the end of each stage (its at the bottom of the page) to compare with your version.

WRECKER

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Whack a Mole Tutorial - Moles not being whacked
« Reply #2 on: July 29, 2013, 01:34:39 am »
Thanks.

The new version fixed my camera.

The issue with my moles not being whacked were due to me not having the Box Collider checked off.

It is hard to compare the completed project to the project I'm working on as unity will only allow one instance to run at a time.
I discovered the unchecked box collider just by looking through everything I thought could be causing the issue.
« Last Edit: July 29, 2013, 01:46:52 am by WRECKER »