Discuss Scratch

fedoraguy
New Scratcher
9 posts

how to pick up new guns, and "switch" to the default gun

I am making a program where the player can pick new guns and “Store” them so the user can switch guns (using the Q or E keys) while still retaining that guns animations, what I mean is, lets say player has a rifle and a pistol, when he walks the walking animations are the same for each gun it carries, I thought I worked it out, only it kept glitching and switching back to the default weapon (sprite) when I stopped walking, it stopped glitching, and I tried to make it so the player could switch back weapons, but it wouldn't work, PLEASE! SOMEONE HELP! I TRIED LOOKING AT OTHER PEOPLES PROJECTS BUT IT WASN'T WHAT I WAS LOOKING FOR! And the tutorials here don't have it, not even on the wiki, so could someone help, I would be most grateful.

Until then I try to figure it out myself.

mwiedmann
Scratcher
100+ posts

how to pick up new guns, and "switch" to the default gun

Take a look at this. It shows a timer based animation with different animations for each weapon type. You should be able to build something using these ideas.

Walking animation with different weapons

Left/Right arrows to move. Spacebar to switch weapons.

Let me know if you have questions.
fedoraguy
New Scratcher
9 posts

how to pick up new guns, and "switch" to the default gun

Thanks! I'll let you know if it worked! or helped me understand it better
fedoraguy
New Scratcher
9 posts

how to pick up new guns, and "switch" to the default gun

Actually, thats not what I meant, check out my project, I've tried everything maybe you can figure out whats wrong, my project is called TEST 01, it has the controls in the notes, pretty basic controls

letmethink
Scratcher
100+ posts

how to pick up new guns, and "switch" to the default gun

fedoraguy wrote:

Actually, thats not what I meant, check out my project, I've tried everything maybe you can figure out whats wrong, my project is called TEST 01, it has the controls in the notes, pretty basic controls


I remixed it to fix the bug:

http://scratch.mit.edu/projects/10543055/
heatguts
Scratcher
100+ posts

how to pick up new guns, and "switch" to the default gun

that seems right for the glitches described.
fedoraguy
New Scratcher
9 posts

how to pick up new guns, and "switch" to the default gun

Well Its fixed now, however I want to make different guns shoot at different speeds, you know rounds per minute….sorta…basically making a script so when you switch weapons, your gun fires faster or slower, depending on the weapon you have
Zparx
Scratcher
500+ posts

how to pick up new guns, and "switch" to the default gun

fedoraguy wrote:

Well Its fixed now, however I want to make different guns shoot at different speeds, you know rounds per minute….sorta…basically making a script so when you switch weapons, your gun fires faster or slower, depending on the weapon you have


Ahh, here try this:

Create a list. Name it “GunSpeeds” Make two variables called {GunSpeedVariable} and {RPM}
Now fill the list with the differing gun speeds.
For example, if you wanted weapon 1 to have a speed of 0.5 RPM, add that to the list first. If you want weapon 3, however, to have a speed of 0.2, make sure you add that speed to the THIRD entry of the list.
Now, put all of the weapons costumes in one sprite.
Name each costume as numbers. So the first one would be “1” yep, just “1”, and the second “2” and so forth
Now you can have this script

When someone changes weapons, set the GunSpeedVariable to whatever weapon in the costumes they switched to. So say they wanted weapon 3, which is a rocket launcher, you would set the GunSpeedVariable to 3, and then have this in your scripts “switch to costume {GunSpeedVariable}”
then you would Set RPM to {item {GunSpeedVariable} of {GunSpeeds}

All you have to do is make sure the costume matches the correct gun speed in the list.

Hope this helped!

Last edited by Zparx (June 4, 2013 15:47:00)

fedoraguy
New Scratcher
9 posts

how to pick up new guns, and "switch" to the default gun

Yeah I sort of fixed that but I didn't use that method, I just created a new sprite, however now I have a whole bunch of new problems I can't seem to fix
ScoutForDays
Scratcher
2 posts

how to pick up new guns, and "switch" to the default gun

I really need to know a script to change weapons
deck26
Scratcher
1000+ posts

how to pick up new guns, and "switch" to the default gun

ScoutForDays wrote:

I really need to know a script to change weapons
Please don't necropost - start your own new topic.
joshuaho
Scratcher
1000+ posts

how to pick up new guns, and "switch" to the default gun

Hey folks - this thread is old. Please feel free to make a new topic if you have a new question related to scripting.

Powered by DjangoBB