Aiming and shooting a boomerang like object

What i am trying to accomplish is when i click a button an object (a small glowing sphere) is shot towards where i was aiming and if it hits an object it can grab, a wall, or goes to far it will return to my character with the object

I know how to get it to collide with the object and parent it, and deparent when to drop it, i just can’t get the sphere to shoot where i have my mouse aimed and then return

Any sort of advice on how i can accomplish this would be great
(all i need is just how to set a max distance, or collision to stop the object from continuing forward and how to get it to aim where the mouse is)

Thank you in Advance ^^;

Implying that you’re using Blender 2.49b:

Well, as long as you keep the boomerang’s speed constant, you can just use a delay sensor to determine its distance, and if you make the boomerang a sensor, as opposed to static or actor, you can just use a collision sensor to detect any collision without screwing up anything.
As far as aiming goes, you could use hitPosition to get the mouse’s position and set an empty’s position to that position, then it would just a matter of having the boomerang, when going and returning, track to the empty and player respectively…

If you need an example, I can probably whip one up nicely… :wink:

Sorry, My laptop had to be sent in for repairs, so i can only reply on school days when i stay after, I can get it to track to where i aim and back to me i just can’t get the “aim” empty to follow my mouse so i can correctly aim it up down left and right.

How about this:
Boomerang.blend (188 KB)

Monster- I tested your boomerang, it looks awesome, but I keep getting it stuck on the target after a few “throws”. Seems like it happens if the mouse is clicked before it returns to the player (edit: after it starts the return trip to the player). The boomerang just spins around the target, and it refuses to change target locations.

This is because the boomerang is an self targetting rocket ;). It aims for the target with an delay. The problem is that it might miss the target. If that happens the boomerang circles around the target without ever reaching it.

Solutions are:

  • smaller the tracking delay (but this makes the curve sharper as well)
  • lower the speed of the boomerang
  • increase the rang of the near sensor at the target.

The blend works perfectly, i just wish i knew how it worked @.@

I love that blend, I love the ideas it brings forth… thanks Monster :slight_smile:

Usually, the way to figure something out is to start from the beginning, which, in BGE terms, usually means starting from left to right.

Initially, the sInit sensor calls the Cursor.show function, and then it changes state of the object to “Point”, so then you look at that state, and you notice that clicking the the left mouse button makes another transition, this time to “Aim” … and you keep going like that, looking at all the actions from one transition to another.

Monster made the connections in a very nice way, so it’s a good example to learn from.

Although, it would be helpful if the message actuators listed the recipients explicitly (at least for those occasions where there is only one recipient - makes it slightly easier to follow).

And, of course, you should ask Monster about something specific that you don’t understand; I’m sure he would help you.

Usaully I wouldn’t use message for interobject communication, as there is a on-to-one relationship betweeen bommerang and target and boomerang and originator.

On the other side I didn’t wanted to directly connect the logic bricks between them together. Beacuse this si not very flexible either.

The best way would be with direct references, but this involves python, and I do not want to let it look it is only possible with a script.

As social said the messages could be send to the one receipient only. That would enable you to add more boomerangs at the same time.