This is a tutorial for you to deal with scripting your custom character in roblox! How is your character made?image853×337 56.6 KB Roblox characters can have different types of structures and can be build in many different ways. Probably if you got to this article you already have your character made, but here are some tips over creating it: Roblox’s default are made with the R15 and R6 structures, so you will save some time if you could rig your char in a way that can copy the R15 or R6 structure. For animating a model without a Humanoid you can use the AnimationController instead. For rigging models on Roblox Studio, try this plugin Rig Editor by @goro7. For some reference of ways on how you can create your character: Bone | Documentation - Roblox Creator Hub Talking about R15 and 16, A common problem with custom created rigs is when the modeler forgets to create meshs facing the right direction. Make sure all your character’s parts face front and your animations will stay consisent over different character types, avoiding this kind of problem (custom rigged character with wrong-faced meshes reproducing the default Rthro walk animation):
Recapping what is inportant: If you are using an R6 or R15 based rig, you will be able to use a Humanoid object without problems and will have no hard time using the default Player’s methods related to the Player’s Character. If you are using an R1 model, you can still rig it with bones to match it with an R15 or R16 model and get the default Roblox’s APIs for characters. If none of the above is possible for you, then you have choosen the “create from scratch” path, where you will get no benefit over Roblox scripts that regards to Sounds, Animations, HumanoidStates, Loading, Respawning, Camera setting and etc. I will talk less about scripting this type of model because scripting it adds a big layer of complexity, but its never impossible. If you want to make it right you will need to fork the default player and character scripts, analyse it and edit for your needs. CharacterAutoLoadsis a Property of the “Player” service, changes if the game will automatically spawn your character when the game begins or when you die. You most likely will prefer that option disabled, specially if you are using an R1 character. LoadCharacterAppearanceTurning “” makes the game not to download the player’s character appearance with the API, that makes the game quickier on iniciation in case your are not going to use player’s characters default appearence. If you use the (needed if “CharacterAutoLoads” is disabled) method with this disabled, the character spawned will be a grey blocky character. Players also have individualy the property to define whenever its appearance will be loaded or not. image1222×636 31.7 KB StarterCharacter, StarterCharacterScripts & StarterHumanoidStarterCharacter [Class Model] StarterCharacterScripts [Class StarterCharacterScripts] StarterHumanoid [Class Humanoid] Many people try to keep changing StarterCharacters in “StarterPlayer” during the game to change characters in the middle of the game, I was doing it until I find out that it leads to lots of weird bugs all over the char, with plenty of APIs not working as it should. Instead I started to create my own script to load the characters. HumanoidDescriptionsHumanoidDescription is an object that stores a description for a Humanoid for R6 and R15 rigs. It can be in order to set a rig’s scaling, clothing (Shirt, Pants, ShirtGraphic), Accessories, Animations and BodyColors. HumanoidDescription | Documentation - Roblox Creator Hub There are also some useful methods that interact with humanoid description on the Players service, like:
Your custom loading function can have the role of spawning and customizing your character on spawn. Roblox have some default functions on Player instance for loading characters and some on Humanoids together with HumanoidDescriptions to customize it. If you are using Humanoids with R15 or R6 rigs, search these links:
I also like sometimes to create a function to spawn a “Blank Blocky” R15 humanoid and customize it after spawn using one of the functions above and adding Accessories, BodyColors and . For weird R1 characters you will need to create a function that clones a characters, puts it in workspace, set the Player.Character to that model, create custom RemoteEvents and Events for Player.CharacterAdded because the default ones wont work, and add your own customization to it. RbxCharacterSoundsIf you have done it all until here and you are working with an R6 or R15 model with a Humanoid in it, it is very possible that you would want to disable the custom walking sound that haunts your rig if it is something like a dragon or an alien - Why would it have that spongebob’s boots sound while walking or climbing? To change or mute default character sounds you will have to fork RbxCharacterSounds and edit it: Hit Play button. Go to Players > Your Player > PlayerScripts Copy “RbxCharacterSounds” Hit Stop button. Paste it in StarterPlayer > StarterPlayerScripts Open it and find the SOUND_DATA table, it contains sound ID’s and Volume. You can take your look on this script to mess with sound related character’s default behaviour, or clear it if its your will. It must stay inside “StarterPlayerScripts” to be used by the game instead of creating a new default RbxCharacterSounds script on spawn. If you want to delete the sound, you can go for deleting the whole walking and climbing sound object from the table (and you will have to find delete all of its calls in the whole script) OR you can just mute it by setting Volume to 0, and muted the SOUND_DATA table should look like this: local SOUND_DATA = { Climbing = { SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3", Looped = true, Volume = 0, }, Died = { SoundId = "rbxasset://sounds/uuhhh.mp3", }, FreeFalling = { SoundId = "rbxasset://sounds/action_falling.mp3", Looped = true, }, GettingUp = { SoundId = "rbxasset://sounds/action_get_up.mp3", }, Jumping = { SoundId = "rbxasset://sounds/action_jump.mp3", }, Landing = { SoundId = "rbxasset://sounds/action_jump_land.mp3", }, Running = { SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3", Looped = true, Pitch = 1.85, Volume = 0, }, Splash = { SoundId = "rbxasset://sounds/impact_water.mp3", }, Swimming = { SoundId = "rbxasset://sounds/action_swim.mp3", Looped = true, Pitch = 1.6, }, }You can also try to change the default sound URL for another URL AnimationsFor R15/R6 Humanoids, Roblox automatically spawns a local script called “Animate” inside the characters. You can fork it to edit and place it in StarterCharacterScripts. It will allow you to change the animations or animation behaviour of your character. Hit Play button. Open your Character in Explorer Copy the local script called “Animate” Hit Stop button. Paste it in StarterPlayer > StarterCharacterScripts Inside the script (instance, not its text) there are values with the action name, go inside the value with name of the animation you want to put yours, click on the Animation object inside it and change it’s ID in properties to your animation’s ID. Attention here: Although there is a “walk” and a “run” animation, the actual normal walking sistem is only using the walk anim, changing “run” seems to rave no effect. And more important: Never use the same animation ID for walk and run animations because it will stop the animations from replicating to server. (责任编辑:) |