frontiers
Pyrite Adventure Fanclub
Working on games (party, RPG, etc.)
Posts: 122
Roblox Username: SonicFrontiers011
Game: Pyrite Adventure 1
|
Post by frontiers on Mar 22, 2024 13:46:07 GMT -8
So recently I've been working on one of my biggest games ever, Pyrite Adventure DX.
This game is receiving a remake to address almost all of the issues. Alongside a new story, abilities, content, and DLCs planned.
So how do I make the homing attack like in PA2? The free homing attack which just gives you a bit more speed, and the lock on homing attack which can be chained into enemies.
|
|
|
Post by SuperJumpman12 on Mar 22, 2024 16:28:39 GMT -8
happy to give some tips! i dont know your scripting knowledge or anything, but i can run through the basics of what we did:
first of all, for the range, honestly, i just made a huge invisible brick and welded it to the player's rootpart. i made sure to give the weld an offset that makes it in front of the player instead of in the middle, and then turned the Massless property in the brick on, so that you're not flinging everywhere.
then, i made a localscript that detects if you hit the jump button after jumping once, and when you do, it uses the :GetTouchingParts() function to get every part that the giant brick touched in that moment to see if anything's in range, like this:
local touchingParts = giantbrick:GetTouchingParts() --gets a table of touching parts
for _, v in pairs(touchingParts) do -- loops through all the touching parts
if v.Name == "HomingTarget" then --tween
end end we named bricks stuff like "HomingTarget" or "Enemy" to see if they're homable, but you could probably use Attributes or even BoolValues and it might work better.
then, like you might be able to guess from the code, i anchored the player's rootpart and just used TweenService to tween it over to the object, then unanchored the player and had the enemy explode. afterwards, i fling the player up into the air by setting their rootpart's AssemblyLinearVelocity to something like (0, 55, 0) ...and that's about it.
...if the function doesn't detect any parts named "HomingTarget" or whatever, then it just simply applies forward velocity to the player, like this:
character.HumanoidRootPart.AssemblyLinearVelocity = character.HumanoidRootPart.CFrame.lookVector * 130 if i were doing it now, i bet you could skip the first step of welding a huge brick to the player by just using Region3 or something, but i was really dumb at the time of making PA2. it was valuable experience, though!
feel free to ask more questions, but definitely look stuff up on the Roblox DevForum if you're ever stuck. there's tons of helpful stuff on there with almost every question you could want. it's how i got through coding that game!
|
|
frontiers
Pyrite Adventure Fanclub
Working on games (party, RPG, etc.)
Posts: 122
Roblox Username: SonicFrontiers011
Game: Pyrite Adventure 1
|
Post by frontiers on Mar 23, 2024 4:56:40 GMT -8
SuperJumpman12I did some thinking and found out that the reason why the wall-jumps in the original Pyrite Adventure DX didn't work was because the HumanoidRootPart was unanchored and that's why the player could fly all over the place. I also got the checkpoints working using Player.RespawnLocation. And on top of that, the hitbox's size is 24, 18, 24. Is that large enough?
|
|
frontiers
Pyrite Adventure Fanclub
Working on games (party, RPG, etc.)
Posts: 122
Roblox Username: SonicFrontiers011
Game: Pyrite Adventure 1
|
Post by frontiers on Mar 26, 2024 6:20:49 GMT -8
Also two questions:
should the largebrick have cancollide true or false? cause it has some weird results when true
what do you use to detect when a player presses space twice?
i used a variable and increased it by 1 every time. that works too right?
|
|
|
Post by SuperJumpman12 on Mar 26, 2024 22:37:20 GMT -8
yup, definitely have have the large brick's cancollide off. it can still detect hits that way, but won't actually collide with any collision. our brick's size is around 25, 25, 48, so it's longest in the front, but you could honestly go a little bigger.
detecting if a player presses the jump button in the air is a little complicated, but ill try to break it down a bit here: firstly, make a variable for the player's humanoid like you usually would. there's different states of humanoids that tell you when the player does stuff, so we can use that to our advantage. like this:
local isJumping = false local debounce = false
humanoid.StateChanged:Connect(function(oldState, newState) if newState == Enum.HumanoidStateType.Jumping then --If they enter a jumping state if isJumping == false then isJumping = true end elseif newState == Enum.HumanoidStateType.Landed then --If they enter a landing state if isJumping == true then isJumping = false debounce = false end end end)
basically, this detects when the player jumps and lands. the isJumping variable turns on to tell if the player is jumping, and the debounce variable will be used to prevent you from spamming the homing attack. both will be used later.
then, you'll have to see if the player pressed a certain button while the isJumping variable is on. we'll have to use UserInputService. try something like this:
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed) if (input.KeyCode == Enum.KeyCode.Space or input.KeyCode == Enum.KeyCode.ButtonA) and isJumping == true and debounce == false then debounce = true HomingAttack() --Make sure to make a function somewhere above this chunk of code that this'll refer to, which actually does the homing attack end end) of course, you have to account for mobile users, too. i hope you're putting this all in a localscript, because we'll have to see if they're using touch controls, then define their jump button UI to see if they press it:
local jumpButton = nil --Put this at the top of your script with the rest of your variables
if game:GetService("UserInputService").TouchEnabled == true then --Check if using touch controls jumpButton = localplayer.PlayerGui.TouchGui.TouchControlFrame:WaitForChild("JumpButton") end
if jumpButton ~= nil then jumpButton.InputBegan:Connect(function(inputObject) if isJumping == true and debounce == false then debounce = true HomingAttack() --Same as before. Only need one function that actually performs the homing attack, then you can call it from anywhere, like here end end) end that's the basic gist of it. it's hard to explain all of the code in a single forum post, but i hope it isn't too confusing and it at least points you in the right direction.
|
|
frontiers
Pyrite Adventure Fanclub
Working on games (party, RPG, etc.)
Posts: 122
Roblox Username: SonicFrontiers011
Game: Pyrite Adventure 1
|
Post by frontiers on Mar 27, 2024 2:09:53 GMT -8
Yeah, but :GetTouchingParts() doesn't run unless CanCollide is true and if I set it to true it causes the player to fling all over the place.
Thank you for your explanation.
|
|
frontiers
Pyrite Adventure Fanclub
Working on games (party, RPG, etc.)
Posts: 122
Roblox Username: SonicFrontiers011
Game: Pyrite Adventure 1
|
Post by frontiers on Mar 27, 2024 2:40:11 GMT -8
I think the problem is either
A. The script is on Client (maybe I should use a RemoteEvent to connect a Server with it) B. :GetTouchingParts() doesn't work when CanCollide is off
|
|
frontiers
Pyrite Adventure Fanclub
Working on games (party, RPG, etc.)
Posts: 122
Roblox Username: SonicFrontiers011
Game: Pyrite Adventure 1
|
Post by frontiers on Mar 27, 2024 3:01:09 GMT -8
I'll figure it out one step at a time. But thanks for giving me basic knowledge of what I'm supposed to do.
And plus, this is only my first Pyrite Adventure game. The second one could be a whole lot better with new abilities like the homing attack.
|
|
|
Post by SuperJumpman12 on Mar 27, 2024 22:39:16 GMT -8
i looked around, and found a post that should solve your problem: devforum.roblox.com/t/obsolete-simple-trick-to-make-gettouchingparts-work-with-non-cancollide-parts/177450it's technically obsolete, but it should still work just fine. i'd recommended you check through the page and all still, to get an understanding of it, but basically, all it's saying to do is to add something like local connection = part.Touched:Connect(function() end) before the GetTouchingParts() line, and then add connection:Disconnect() near the bottom, after the GetTouchingParts().
|
|
frontiers
Pyrite Adventure Fanclub
Working on games (party, RPG, etc.)
Posts: 122
Roblox Username: SonicFrontiers011
Game: Pyrite Adventure 1
|
Post by frontiers on Mar 28, 2024 2:38:05 GMT -8
Thank you!
|
|
frontiers
Pyrite Adventure Fanclub
Working on games (party, RPG, etc.)
Posts: 122
Roblox Username: SonicFrontiers011
Game: Pyrite Adventure 1
|
Post by frontiers on Jun 18, 2024 11:24:02 GMT -8
It worked! THANK YOU SO MUCH!
Edit: It worked, but after the tween, the character sort of goes upside down and this weird thing happens.
|
|