Beginner in need of help! Thanks -

I’m very new to these programming languages (though I’ve used HTML and Actionscript a lot, so the logic part of it is familiar). I’ve completed just about every tutorial I could find and have really learned how to use the editor, created and imported my own assets, etc. Now I’m on to scripting, and I definitely need some help on basic concepts!

First, I’m working on some VERY rudimentary AI. A monster that walks and changes random direction every few seconds. I’m able to set up his walk animation AND get him to move, however these are the problems I’m experiencing:

  1. He walks right through the terrain. I set up a capsule collider with the monster and I wouldn’t doubt there’s something more I’ll have to do, but I can’t figure out how to get him to walk ‘up the hill’ instead of through it.

  2. I can not get it to set a random direction. I created a function which I thought was generating a random number between 0 and 360, set the rotation to that…however the character always rotated to the same place, not random at all…

  3. Also, I thought ‘Vector3.forward’ would change based on the rotation, but even when i did successfully get my monster to rotate, forward was always the original facing direction even though now my monster was facing that new direction.

  4. Trying to set up a timer so that it can call the random function after x amount of seconds.

I know these are some very basic things, and I appreciate you pros who are willing to give your time to a hobbyist like me who is intruigued by Unity and implored to take it to the next level!

Thanks!

If you’re using Transform.Translate, that will move things through solid objects. In order to properly use the physics, you need a collider + rigidbody.

Then, all you have to do is make him move by changing the rigidbody.velocity or by using rigidbody.AddForce(). ^-^