ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 03:09 AM |
Hey guys! I'm currently working on a 2D side-scrolling game and it's nearing completion! However, I just can't figure out how to animate the characters in the background (cycle between decals) or the background itself (sorry, I'm a scripting newbie)! Thanks!
Happy New Year! ChubbyXD |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 03:34 AM |
I would guess it would go something around changing the textureID of the decal.
A decal is a decal in ROBLOX Studio, meaning they are all the same, you just insert the ID of the decal in from the site to make it whatever that image is.
In the decal, insert a script. Insert the following into the script:
local decal = script.Parent
local image1 = "http://www.roblox.com/asset/?id=1" local image2 = "http://www.roblox.com/asset/?id=2" local image3 = "http://www.roblox.com/asset/?id=3" local image4 = "http://www.roblox.com/asset/?id=4" local image5 = "http://www.roblox.com/asset/?id=5"
local images = {image1, image2, image3, image4, image5} --you can add as many as you want, as long as you identify them such as how i did above this.
while true do for i,v in pairs(images) do decal.Texture = v wait(1) --how long you want between each decal in seconds end end
----
For the robloxassetid things, those are your decals you want them to alternate between, in that order.
To get the number that goes at the end, take the URL of each decal, for example one of yours:
http://www.roblox.com/shroom1-item?id=200402558
to get the asset id, take only the numbers from it
200402558
now subtract one
200402557
so the asset ID for it is 200402557, and you use it in a script you reference it as "http://www.roblox.com/asset/?id=200402557"
to put that in my script, you would just change
local image1 = "http://www.roblox.com/asset/?id=1"
to
local image1 = "http://www.roblox.com/asset/?id=200402557"
and do that for image 1-5
and if you have more after that, simply follow the pattern and you can add as many as you want.
IF YOU HAVE A LOT, LIKE A THOUSAND OR ANYTHING MORE THAN 25 DECALS, I WILL WRITE YOU A DIFFERENT SCRIPT WHERE YOU DON'T HAVE TO WRITE OUT ALL THE ASSET IDS
because that's tedious af
otherwise, enjoy :)
-dado |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 03:36 AM |
| btw 99% of those links won't work, you aren't meant to click on them or go to them, you are meant to use them in the script exactly how I said |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 03:37 AM |
If that was unclear, ask.
The structure should be
Part>Decal>Script |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 03:51 AM |
| Hollyyyyyyyy!! Million thanks!!! I'll try the script right now! |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 03:55 AM |
| Remember, the script has to be in the decal, because its not inserting new decals, it is changing the texture of it to your different images. |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 03:57 AM |
Works like a charm!
love you bae |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 03:58 AM |
| Out of curiousity, how many decals are you using? |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 03:59 AM |
| 3 for characters and 2 for the background! I removed the unused "image#" variables c: |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 04:04 AM |
| that's great, i'm glad i made a script that works for your situation |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 04:12 AM |
One more thing Mr./Mrs. DoAndDoOver!: I really don't want to use up your time, so answer this wall of text only if you have the time, but my game also has this "animation" script for the 2D characters morphs! I am wondering how the script could be altered to cycle through four walking images instead of the two and how the script could be altered to include an idling animation (specifics: cycle through 3 images). I tried to do my wacky if-elseing, so the animation got all jumbled up!
--------------------------------------------------------------------------------------- DECAL = script.Parent.Decal humanoid = script.Parent.Parent.Parent:findFirstChild("Humanoid") running = false DecalId = "http://www.roblox.com/asset/?id=37490122" DecalId2 = "http://www.roblox.com/asset/?id=50848689" --walking image 1 DecalId3 = "http://www.roblox.com/asset/?id=50848701" DecalId4 = "" DecalId5 = "" DecalJump = "http://www.roblox.com/asset/?id=50848715" jumping = false
function Run(speed) if speed > 0 then running = true else running = false DECAL.Texture = DecalId end end
function Jump() DECAL.Texture = DecalJump end
humanoid.Jumping:connect(Jump) humanoid.Running:connect(Run)
--All you have to do is change the DecalId things. The first one is the "Not walking" picture, next two are walking, and Jump is jumping picture.
while true do wait(0.2) if running then if DECAL.Texture == DecalId then DECAL.Texture = DecalId2 elseif DECAL.Texture == DecalId2 then DECAL.Texture = DecalId3 else DECAL.Texture = DecalId2 end end end --------------------------------------------------------------------------------------- |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 04:22 AM |
I am wondering how the script could be altered to cycle through four walking images instead of the two and how the script could be altered to include an idling animation (specifics: cycle through 3 images
--
so by 4, you just mean 4 decals?
which you could do by using the script i gave you minus the last one:
local decal = script.Parent
local image1 = "http://www.roblox.com/asset/?id=1" local image2 = "http://www.roblox.com/asset/?id=2" local image3 = "http://www.roblox.com/asset/?id=3" local image4 = "http://www.roblox.com/asset/?id=4"
local images = {image1, image2, image3, image4} --you can add as many as you want, as long as you identify them such as how i did above this.
while true do for i,v in pairs(images) do decal.Texture = v wait(1) --how long you want between each decal in seconds end end
---------------------------
and by idling you mean showing no decal, or do you mean showing the same decal?
if you plan on doing mulitple sets of animation with breaks in between, I would definitely alter the script. |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 04:25 AM |
You have definitely been innovative, which I guess you have to be whenever you are combining scripts.
I can help you with this, but explain to me again what you are trying to do. |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 04:30 AM |
Yes, four decals! I apologize if I was unclear! This pertains to an animated character morph. :P When the player is walking, I want to cycle through four decals as the walking animation ( the script I pasted is from this Model, but it uses two decals for the walking animation http://www.roblox.com/Qwertygiys-2D-Paper-Animated-Morph-System-FREE-item?id=39766515 ) and I want to cycle through three decals when the player is standing still!
- ChubbyXD |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 04:35 AM |
One tiny bit of information I need.
Where is the decal? |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 04:41 AM |
| Sorry about that! Here's a layout of one of the morphs: http://puu.sh/e3njL/3ea68671e7.png |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 04:44 AM |
| Addendum: "Decal" is the decal on the front of the character morph and "Decal2" is on the back of the character morph. The two scripts listed above the two decals have the script I pasted (the second script modifies "Decal2") |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 04:52 AM |
Alright, I am starting to get something written.
I want you to link me the walking images only, in the order you want them to run. |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 04:52 AM |
| the actual links, not the asset id links |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 05:05 AM |
Okey-dokey~
1) http://www.roblox.com/bw1-item?id=199897194 2) http://www.roblox.com/bw2-item?id=199897254 3) http://www.roblox.com/bw3-item?id=199897301 4) http://www.roblox.com/bw4-item?id=199897336 |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 05:12 AM |
| Now, link the standing and jumping pics and tell me which ones they are |
|
|
| Report Abuse |
|
|
ChubbyXD
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 306 |
|
|
| 04 Jan 2015 05:21 AM |
-Standing- 1) http://www.roblox.com/bstill1-item?id=199897122 2) http://www.roblox.com/bstill2-item?id=199897140 3) http://www.roblox.com/bstill3-item?id=199897166
-Jumping- http://www.roblox.com/bjump-item?id=199903202 |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 05:37 AM |
--Change this number to change how many seconds you want each decal to be visible local waitTime = 1
local decal = script.Parent.Decal
local standing = false local walking = false local jumping = false
--##ASSET ID VARIABLES##-- local stand1 = "http://www.roblox.com/asset/?id=199897121" local stand2 = "http://www.roblox.com/asset/?id=199897139" local stand3 = "http://www.roblox.com/asset/?id=199897165" local standingImages = {stand1, stand2, stand3}
local walk1 = "http://www.roblox.com/asset/?id=199897193" local walk2 = "http://www.roblox.com/asset/?id=199897253" local walk3 = "http://www.roblox.com/asset/?id=199897300" local walk4 = "http://www.roblox.com/asset/?id=199897335" local walkingImages = {walk1, walk2, walk3, walk4}
local jump1 = "http://www.roblox.com/asset/?id=199903201" local jumpingImages = {jump1}
--##STANDING##-- while standing do walking = false jumping = false for i,v in pairs(standingImages) do decal.Texture = v wait(waitTime) end end
--##WALKING##-- while walking do standing = false jumping = false for i,v in pairs(walkingImages) do decal.Texture = v wait(waitTime) end end
--##JUMPING##-- while jumping do standing = false walking = false for i,v in pairs(jumpingImages) do decal.Texture = v wait(waitTime) end end |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 05:39 AM |
| That's a set up so that whenever the word standing, walking, or jumping gets set to true, it will cycle through the appropriate images until another one is called true. |
|
|
| Report Abuse |
|
|
|
| 04 Jan 2015 05:42 AM |
Here's the exact same script, but with proper indents
http://codepad.org/TzJxaqlR
roblox forum gets rid of the indents and i hate that |
|
|
| Report Abuse |
|
|