Help with Mobile key conversion

I have this JetPack and have been perfecting it for a long time. It runs well now, and I am looking to add mobile support. Right now it runs off a second jump in the air while pressing the W key. I have messed with it a bit, and to be honest, I am finding it hard to even tell they did a jump or a second jump. I really hope there is something I am missing to convert the keys used to mobile controls W, A, S, D, and Jump. I keep putting this off, but now I am at the point where the JetPack, and also a winged version, only needs this last part added. Any thoughts or direction would be appreciated.

1 Like

For distiguishing between a first and second jump, you can probably use FloorMaterial. As for converting to mobile, it seems reasonable well documented Jump Stuff Thumbstick. Found these by looking around for 30 seconds, so they may not be the best, but i’m sure there’s much, much more out there.

I am testing if they are in the air, in a falling state.. I’ve got all that working well. It’s just the keys I need to test for on a mobile I’m having problems with.

I had this in place.. Is there anyway to just add mobile keys to this..

local validKeys={
	[Enum.KeyCode.W]=true,[Enum.KeyCode.A]=true,
	[Enum.KeyCode.S]=true,[Enum.KeyCode.D]=true,
	[Enum.KeyCode.Up]=true,[Enum.KeyCode.Down]=true}
local flightKeys={
	[Enum.KeyCode.W]=true,[Enum.KeyCode.Up]=true}
uis.InputBegan:Connect(function(input)
	if Flying and validKeys[input.KeyCode]then Snd3:Play()
	elseif flightKeys[input.KeyCode]then flight=true
	end
end)

uis.InputEnded:Connect(function(input)
	if flightKeys[input.KeyCode]then flight=false end
end)

Maybe instead of detecting key inputs, you could use humanoid.Movedirection. Then just do some math (idk what math I’m not good at it, maybe ask AI) to see if the player is moving in the general forward direction.

This should support all methods of moving forward, including mobile, since move direction should work for all movement methods.

I need it to be able to turn also.. maybe Thumbstick was what I missed

You should be able to detect turning with this too, it just may be complicated.

Maybe make a table with all movement directions, then set all of the values to 0. Then, when a player moves in a certain direction, you could increase the number, max being 1.
Here’s an example:
If the player is moving in a diagonal, forward and left, your table would look like this:

local direction={
	forward=0.5, left=0.5,
	backward=0, right=0,

(You could also have just x and z, then have a value between -1 and 1)
(Btw, you would decide the values in this table from humanoid.MoveDirection)

Then, just change the rest of your code to take a value between 0-1, instead of a boolean (so 0 or 1).

This is probably hard to do, but I think it’s a decent way to do this.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.