playMaker

Author Topic: Moving game objects randomly within a specified area..  (Read 1485 times)

mokona99

  • Playmaker Newbie
  • *
  • Posts: 3
Moving game objects randomly within a specified area..
« on: October 12, 2015, 01:00:28 PM »
Hi all, I was just wanting some input and advice on how I can go about moving a specific game object within a specified area in the game world.

My scenario involves two guns floating in mid air facing each other and firing at each other. I have them firing randomly, but I'm wondering how I can move them around a specified area, say a sphere I specify and move from point to point within that sphere after getting a shot off.

Thank you for those who are able to respond!  :)

moondust.games

  • Playmaker Newbie
  • *
  • Posts: 46
Re: Moving game objects randomly within a specified area..
« Reply #1 on: October 13, 2015, 03:02:41 PM »
If you ascertain their start position,say x=0, y=0, z=0 then you can add a random value to each axis (say between -10 and +10) and set the location to the new x,y,z. Start each random from the original origin and you'll get your guns moving around a cube shape where the original position is in the center.

Another way to keep the gun on the edge of a sphere shape would be to make the gun a child of a parent actor and move the child out by the max distance you want. Then rotate the parent randomly and keep the child always facing forward using clamp. Now your gun will randomise around the sphere (but not positions inside the sphere)

Hope these help.