Thanks , I played around with it and am now getting more of a organic feel to the game.

A problem I'm having now is keeping the fish confined to the tank area. My solution to this is create a collision script for the fish and when ever a trigger is detected between the fish and the wall , move the fish in a new direction.

The problem is that although I'm in the early stages of setting this up, I cant seem to get the code bellow to print anything to the console:

Hiya apple741 -- if you aren't seeing an Trigger messages and you are running your fish through the wall, then I'm guessing one of the two doesn't have a rigidbody attached to it.

For this particular example, I'd probably use the following:

1) Static Colliders for the tank walls
2) Fish with Sphere Trigger Collider and Rigidbody attached
3) Use Physics.Raycast periodically to give the fish a sense of where the tank wall is in front of it so you can apply a more organic feel of steering instead of >bonk< run into a wall and then do the turn
4) Regardless of implementing the Raycast, the combo of static collider + rigidbody trigger collider will get the trigger messages flowing as you're expecting in your example

Hey again apple741 If you're good to go now great, let me know...anyway, to answer this post:

One problem I'm having is that Im checking for collisions with the walls using triggers which means the fish currently go through the walls.

Click to expand...

Rule of thumb here is you must pick one or the other between Collisions and Triggers. If two objects collide, and either has a trigger set, you get no Collision message (hence why the fish sails on through the wall, even though raising a Trigger message).

Collision Approach:

Walls = Static Collider
Fish = Rigidbody Collider

1) Box Colliders only on the walls, and check the Static checkbox under those game objects
2) Box Collider on the fish (isTrigger unchecked), and a Rigidbody on the Fish
3) Move the fish around by applying forces
4) Physics engine and colliders will keep the fish in the tank

To verify that setup works you can forget about movement for the moment, just check useGravity on the Rigidbody and see if the fish falls and stops on the bottom tank collider.

Trigger Approach:

Walls = Static Collider
Fish = Kinematic Rigidbody Trigger Collider

1) Box Colliders only on the walls, and check the Static checkbox under those game objects
2) Box Collider on the fish (check isTrigger), Rigidbody on the Fish (check isKinematic)
3) Move the fish around by modifying its transform.position
4) You are responsible for keeping the fish in the tank (i.e., when a trigger message fires clamp its position to keep it from advancing further in whatever x/y/z axis)

hello, I'm new to unity and I'm trying to move a fish in the aquarium, but there are still successful.
can you sent me the complete script for the random miovimento fish with the collision, thank you very much.