Help! My Fantasy Tower Defense Isn't Working

I guess visiting here I’m not as original as I thought -looks like a lot of people were going the Fantasy route.

At any rate, I got this awesome Spider asset to have a giant spider attacking my tower. But, now I’m stuck there.

No matter what I’ve tried thus far, my spider gets thrown into the cubes when animating it when I add the script. At first, I tried adding it as a child of the “enemy” prefab and just replaced the body. But, even when I put it in on its own and place it properly (or so I think), it ends up walking underneath/through the cubes.

The thing is, the transform on the gameplay still shows it moving properly from 0 to 10, 20, etc…I have no idea what to do…

Here’s without the script:

Here’s with the script:

I’ve been mostly just following along but REALLY want to make this one my own. Guess I’ll work on the texture of the environment for now (and building enemy/ally base) but have no idea what else to try on this…

Edit: Also, I’ve tried removing the animator thinking that my conflict -changed nothing.

Hi Joseph,

Have a look at the animation you have created, has the position for the GameObject been set in the animation?

I actually got it from the asset store, so not sure how to do that. Would that be like using Timeline in Aragon Assault?

Either way, I did try to remove the “Animator” component entirely, and it still stays in the wrong place. After doing some of the landscape assets, I actually tried a different enemy entirely from the asset store -same problem though…here’s a look:

Again, thanks for having a look!

Hi,

It was actually the “animation” I was referring to rather than the “animator”, it’s a different window.

That said, if you have used another asset and had the same issue I get the feeling that perhaps the issue is with the grid they are traversing.

If you select one of you blocks, what is its transform position and scale?

If you are happy to zip up your project files I wpuld be happy to take a quick look, would be in about half an hour.

The forum will allow uploads of up to 10MB, if your project files (zipped) are larger than that you would need to use a service such as Google Drive or Dropbox, and then share the URL.

That would be awesome Rob! Here’s a link to the file as it went to about 20MB zipped: https://www.dropbox.com/s/9p5oept9ryhlxfr/Tower%20Defense.zip?dl=0

I can see the tileset does not actually start at 0,0, so I guess I did screw up right out of the gate -guess I didn’t realize how important that was. When I play on the inspector I can see movement starts at 0,0,0 -not sure how to adjust grid to fit in there.

What confuses me is this…if I put back the capsule enemy in the scene to replace the dragon, the capsule moves properly. Why would the position affect one but not the other?

1 Like

Hi Joseph,

Ok, I’ve got about 30 minutes before I need to go out, so this is what I can see so far.

  • the spider prefab (spider01) appears to be missing its mesh, so it appears invisible
  • decided to use the dragon instead
  • dragged into the hierarchy, run the game, dragon falls a little
  • stopped the game
  • checked the transform details of the dragon, the Y is set to 5 initially
  • checked the transform details of the capsule, the Y is set to 0.9, but the body child GameObject is set to 10 and has a scale on all 3 axis of 5
  • added a cube and reset its transform to get some indication of where the origin was;
  • noted that this is the same position that the dragon falls to
  • looked at the terrain GameObject
  • looked at the ocean GameObject
  • looked at the tileset GameObjects
  • noted all of the differing values for the transforms, especially on the Y axis

What you have here is a lot of different values being set all over the place, I think you need to backtrack a little to tidy things up, make a backup of the project first though, then go about placing everything based on the origin. At the moment you have empty GameObjects which you are using to parent the actual GameObject you want in the scene but you have a mixture of transform positions being set on then both the parent and the child, this makes it quite confusing with regards to resolving issues like this. So, the above is my advice, backtrack, right back to getting the terrain/ocean at 0, 0, 0 and go from there. On that note, I’d probably put the tileset blocks at 0 on the Y and then just lower the ocean.


So, the following is what I did with what you have to get a dragon moving on the correct level;

  • created an Empty GameObject, named it Dragon Parent (temp name)
  • reset its Transform component to 0, 0, 0
    image
  • dragged in a Dragon prefab as a child GameObject to Dragon Parent
    image
  • reset the child GameObject’s Transform to;
    • position 5, 5, 5

    • rotation 0, 90, 0

    • scale 1, 1, 1
      image

      image

  • removed the EnemyMovement.cs script component from the dragon Child GameObject
  • added the EnemyMovement.cs script component to the parent Dragon Parent GameObject
  • disabled the Enemy (the capsule) as errors occur due to the sharing of the same List (pathfinding)
  • ran the game

I also noted that you are receiving a lot of the overlapping messages, might be worth checking.


As tempting as it may be to set things up based on where the ground currently is, as you have already identified you hadn’t reset this at the beginning, I would recommend going back through and taking the time to correct that, so that going forward you will be able to more easily diagnose the issue.

I hope the above helps a bit. :slight_smile:

Woah! Thank you sir!

I appreciate you going through the entire process like that -really helps me understand how you got there. I’m thinking those overlapping blocks are from me trying yesterday to fix things by moving the map around…

I’ll definitely go through and get things corrected and post an update when I have it done.

Thanks a bunch Rob -you’re the man!

1 Like

You’re very welcome.

Incidentally, I really like the concept you have with the ground blocks and the ocean moving up and down, looks good. Keep going and please do share more updates.

Any problems, just reach out :slight_smile:

Privacy & Terms