Explosion / Bounce Problem
I'm trying to have a spaceship actor fly through space by 'bouncing' off of taps. I figured the best way to do this would be to treat the taps like explosions and have the spaceship react accordingly. I watched tshirtbooth's tutorial on explosions ().
The video used boxes, so I decided to first try to have a box explode and push the spaceship, instead of using taps. I followed the instructions exactly but for some reason the spaceship shoots off in a seemingly random, but fixed direction (fixed as in every time I reset the scene it shoots off in the same direction).
I believe I located the problem to be within the "(vectorToAngle(-(game.BlastX- self.Position.X ),-( game.BlastY - self.Position.Y )))" function, because when I toggle it off, the problem doesn't persist.
Can anyone tell me what I'm doing wrong? Or perhaps suggest a better way to have the spaceship 'bounce' off of taps? Any help would be greatly appreciated!
Comments
Not sure what "a seemingly random, but fixed direction" means.
The issue is probably in the vectorToAngle function as you surmised. Are you sure you have all the parentheses? Are you missing a minus sign?
Seemingly random as in I can't figure out what is causing the ship to travel at that specific angle. Fixed as in it consistently travels at that angle, every time I reset the scene.
The vectorToAngle function above I copied and pasted straight from the expression editor.
The problem could, however, lie within the behaviors of the box, since the expression is made up of "Blast X" and "Blast Y", which are attributes that are modified by the box.
OK on "random" but remember that in game development, it is a technical term (as in "random number").
Is the actor heading toward 0,0 (lower left corner)? Or is it heading straight right? That could be a clue that the expression is broken and evaluating to zero.
Its probably going to be a guessing game unless you post a picture of your 'code'. Or perhaps you could attach a copy of the 'game' so that someone can take a look at it.
Oh sorry about that I'm new to this.
The ship heads towards 0,0 when I remove the 2 negative signs from the expression. When I leave them in, the ship heads the opposite direction.
Anyways, how can I attach a copy of my game? I uploaded it to my portfolio but it doesn't seem accessible to anyone but me.
You probably need to be a pro member before you can attach files to the forum. You could save it to a hosting site like dropbox and then put a link in your forum message.
Meanwhile, here is a working copy. You can compare it to yours and see if you spot any differences.