Shooting an actor at another actor
daniel.robert.campbell
Member Posts: 251
It's time for Daniel's "Super Noob Question of the Day!"
I am having trouble. I have a set of crosshairs, I have a ball at the top of the screen. I have the crosshairs tracking the mouse.
When the mouse button is pressed, I want the ball to be launched at the crosshairs. I have no idea how to do this. Please help?
I am having trouble. I have a set of crosshairs, I have a ball at the top of the screen. I have the crosshairs tracking the mouse.
When the mouse button is pressed, I want the ball to be launched at the crosshairs. I have no idea how to do this. Please help?
Comments
crosshairX (real)
crosshairY (real)
inside your crosshair actor do this:
constraint game.crosshairX = self.position.x
constrain game.crosshairY = self.position.y
in the ball actor:
on mouse down
change velocity angle: vectorToAngle(game.crosshairX - self.position.x, game.crosshairY - self.position.y) speed: 300
So...when you say "constraint" on the crosshairs, you mean "constrain attribute" right?
I went ahead and did that along with the behaviors to get the crosshairs to follow the mouse. Now when I preview, the crosshairs are not visible at all. :-(
Again, thanks a ton for the help.
Thanks for the help. I owe you a big nasty Dan hug. ;-)
Is there any kind of known bugs about this kind of thing?
We ended up fixing it by using timers. we put a timer of 0.1 seconds on the "vector to angle" attribute. And another time of 0.2 (this one was run to completion) for the accelerate down behavior.