Get weapon actor to move up and down

JayReiterJayReiter TexasMember Posts: 88

I'm working on a shoot em up. I'm designing a multiple weapons system for the game. One of the weapons, called a Wave beam, I want to go up and down as it scrolls across the screen from the spawn point. I kind of want it to look like a ball going up and down over and over again as it goes across the screen. Any ideas on how to do this? Thanks.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    A wave would need to be a sin function. Read up on those or check out @Socks' recent demos on the Spare Code thread.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    Constrain its Y position to:

    AAA * sin(self.time * BBB) + CCC

    AAA= the height of the wave

    BBB= the speed of the up down movement

    CCC= the position of the gun

  • SocksSocks London, UK.Member Posts: 12,822

    @JayReiter

    Here's a quick demo file, up and down arrow keys move the gun, space bar fires.

    Link: https://www.mediafire.com/?e1yv7s30ewgb1o2

  • JayReiterJayReiter TexasMember Posts: 88

    Thanks to the both of you. @Socks Your demo is great. I haven't quite gotten mine perfect but it definitely works. I seem to be having a hard time with getting the starting point of the blast right. The first time the weapon fires, the beam actor is spawned at the very bottom of the screen, regardless of what the player actor's coordinates are. Then after the first initial blast is spawned, the remaining spawns are more or less tied to the player's coordinates.

  • SocksSocks London, UK.Member Posts: 12,822

    @JayReiter said:
    I seem to be having a hard time with getting the starting point of the blast right.

    Yeah, if you are using a sine wave that is taller than the mouth of the gun then you'd need to start with a shorter sine wave and interpolate it to the height you want the wave to be.

    That's what I did with the demo, so that the wave comes out of the end of the gun.

    @JayReiter said:
    The first time the weapon fires, the beam actor is spawned at the very bottom of the >screen, regardless of what the player actor's coordinates are. Then after the first initial >blast is spawned, the remaining spawns are more or less tied to the player's coordinates.

    Sounds like your code is set up wrong.

  • JayReiterJayReiter TexasMember Posts: 88

    I'm going to post screen shots of my code for you to look at @Socks. Just as soon as I have some free time here.

  • SocksSocks London, UK.Member Posts: 12,822

    @JayReiter said:
    I'm going to post screen shots of my code for you to look at Socks. Just as soon as I have some free time here.

    I'll take a look when you post it.

  • JayReiterJayReiter TexasMember Posts: 88

    [photo WaveBeamProblemJetActor.jpg]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo WaveBeam.jpg]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo WaveReverse.jpg]

  • JayReiterJayReiter TexasMember Posts: 88

    Ok. The YouTube link shows what the wave beam is doing. I have two wave beams, one on top, one on bottom. That effect is working great. I just can't seem to get the beam to link properly to the player. Let me know if you need me to grab any more snapshots @Socks

  • SocksSocks London, UK.Member Posts: 12,822

    I'd really need to see what's in those expression boxes !

  • JayReiterJayReiter TexasMember Posts: 88

    Right. That makes sense. Lol. I'll get on that.

  • JayReiterJayReiter TexasMember Posts: 88

    [photo Screenshot35.png]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo Screenshot32.png]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo Screenshot30.png]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo Screenshot29.png]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo Screenshot31.png]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo Screenshot34.png]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo Screenshot33.png]

  • JayReiterJayReiter TexasMember Posts: 88

    [photo Screenshot28.png]

  • JayReiterJayReiter TexasMember Posts: 88

    @Socks I think that's everything. :)

  • SocksSocks London, UK.Member Posts: 12,822

    Sorry too much info for me to trawl through !!! I thought it would just be the rules for the problem bullets . . . . : (

    Is the first bracket around self.time*700 a square bracket ? . . . [ . . . .

    If you up load your project I would be happy to take a look at it, if you don't want me to steal it, then just delete all the stuff you don't need, just leave one or two actors displaying the issue.

  • JayReiterJayReiter TexasMember Posts: 88

    The brackets are normal ( and ) brackets.

  • JayReiterJayReiter TexasMember Posts: 88

    @Socks‌ This is the conversation that I sent you the game from. :)

Sign In or Register to comment.