Spawn Actor at a certain location
I am watching the tutorial of the brick breaking game, But on the videos he is using the mac version. Most of the differences so far I have figured out on my own. But now I am on the last video and he destroys the ball, and re spawns it at the top of the screen. I wrote down the x and y position of my ball I want it to spawn x 293 y 881. But no matter what I try I cant seem to get it to work. The ball destroys like it should but it will not respawn, I actually tried to add the rule to the ball since you can pick self inside the ball. But he adds the code on the bottom wall, That we recreated and called destroy.
I added a pic I need to know what I put in the from position section and wouldn't make more since to put this rule under the ball instead of the destroy?
Comments
@JDMorriosn the x,y values you give, would go in the "from" position.
The reason that it does not spawn is probably due to the fact that the game.Destroy attribute gets set to false before the bottom wall actor gets processed.
Can you post the code of the ball being destroyed and the game.Destroy attribute being reset please.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Here is a screen shot of the ball being destroyed, the bottom wall actor is game.destroy. I dont understand why in the tutorial he respawns the ball from the game.destroy and not the ball its self.
why couldn't I add the actor spawn under the destroy this actor from the rule inside the ball. Instead he has you create a new rule say when game.destroy is set to true do: respawn the ball at this location
@JDMorriosn there are always multiple ways to achieve the same goal.
So, yes you could just spawn a new ball and destroy the old one in the ball actor.
Or, just change the x and y of the current actor, to the new position without destroying the actor.
The code you post still does not give enough detail as to how game.Destroy is used. When is it set, does it get set to false at some point, etc.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
ok here is all the code that has to do with the ball and game.destroy and no the ball is never set to false which also confused me. I am new to gamesalad but not new to visual programming or programming in general. I have used UDK, Unreal, torque, Blender, Unity and more. Actually have a degree in game design but programming is not my best area of expertise lol!
The first pic is all the code under the ball the second pic is all the code on the bottom wall which I have named destroy, I created a global attribute called destroy hence the game.destroy
lol thanks for the help @Hopscotch I figured it out you were right I never changed game.destroy back to false that was the problem!
@JDMorriosn I notice that your "if game.Destroy is true" rule in your wall actor is switched off. This would of course prevent the ball from spawning.
Another question, when do you actually set game.Destroy to true? In the wall actor in the "collide with ball" rule?
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
It is set to true in a rule at the top of the destroy code aka bottom wall I have a change attribute. First I have if the actor collides with the ball change attribute destroy.game to true. Then another rule below that stating if destroy.game is true spawn actor the ball then I added change attribute set destroy.game to false under that. At first that did not work either. Because I had the bottom wall still set to movable so of course it fell into nothingness. Once I fixed that it works as it should
Happy you got it sorted out
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com