Spawn object at multiple angles?

0 favourites
  • 7 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hi there,

    I have a shooting thing on the ground that spawns an object (red ball in image) with the bullet behavior. The bullet fly up but I've added gravity to the bullet behavior so the object will eventually come down again. On it's way down, I want it to spawn a new object (green ball in image) 3 times but at 3 different angles.

    I know how to spawn an object and set the angle. I know how to spawn it 3 times. I don't know how to spawn it 3 times with 3 different angles. Do you?

    Thanks in advance,

    Tommy

  • Sinus & Cosinus are the answer. One way to do that:

    Trigger once (or whatever triggering),

    For -1 to 1 --> create object greenBall at x = redBall.X+100*cos(90+30*loopindex)

    y = redBall.Y+100*sin(90+30*loopindex),

    set greenBall.angle to 90+30*loopindex

    Should works.

  • Edit: It was just me being stupid, your solutions works great! I forgot to delete an action and that's why the 4th ball was created. You are awesome, thanks once again!

    alextro - First of all, a thousand thanks for helping me out. I really appreciate it :)

    Sinus & Cosinus is completely new to me. I did what you said without fully understanding what I was doing but it worked. I do have one problem though, there are 4 balls created. 3 of them work exactly like I want but there's a 4th ball being created. The 4th ball has an angle of 0 and I want to get rid of that one. Any suggestions? Thanks again :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • How do you set the loop? If the input are from -1 to 1 it gives you 3 iterations (-1, 0 and 1).

    edit: Oh didn't see that coming ;)

  • alextro - I'm gonna have so much fun this new knowledge haha.

    I checked out your games btw and I'm currently playing Gimme Pipe (level 7) and I just wanted to let you know I really like your game :)

  • Aww thanks. The game was born after I tried to solve other user problem related to his game mechanic. I planned to create an evolved sequel from this pipe game with new twist that rotates pipe by creating a route.

    onicstudios.wordpress.com/2021/11/13/move-turn

    The project status is pending and will back to it probably next couple of months.

  • alextro - I look forward to play sequel :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)