# Custom Skateboard

So, recently I’ve been very intrigued in creating a custom skateboarding system, and have at least got myself moving, literally.

I’m currently using 2 Vector Forces & 1 Torque Force to make the skateboard move.

The Green Force is a Torque Force, used to rotate the board. This force is applied locally to the board revolving around the Y axis of the middle attachment.

The Blue Force is a Vector Force, used to make the board go straight. This force is also applied locally to the board in the X-Axis, and is only utilized to make the board go forward.

The Red Force is a Vector Force, used for Jumping. This force is applied based on the World, in the Y-Axis so no matter what way the board is facing, it’ll go straight up. (So if you’re riding up a Quarter Pipe you could jump off and go higher, rather than jump away from the ramp)

While this system has worked to move around on the ground, I’ve ran into 3 problems that I’ve spent a fair bit of time brainstorming without any idea of what to do to fix them. So, I’m heading to you guys to see if you guys have any suggestions or background in fixing things.

## Problem 1:

When you jump, and are moving forward & turning, you still do both of these in the air. The preferred idea is to continue moving forward in the air, but the rotational torque will only spin the board & player, not cause them to turn in an arc.
https://gyazo.com/933c8290ba067723d62fede4f7eb7350

## Problem 2:

When letting go of forward, I immediately come to a stop. This is because I set the Force from (2000, 0, 0) to (0, 0, 0) but preferably I’d like to not come to a stop. Because vector is a force, the player will constantly speed up if I setup a constant force so I setup if the player moves above a certain speed, set the force to 0. This works while the player presses W, but doing that check constantly while it’s “idling” around doesn’t work out. (On Server it stops & goes. In the player’s local scripts, it doesn’t limit their speed.)

Stop on a dime without an Idle:
https://gyazo.com/117ec0c393a34361d7ff42d11c1afddf

## Problem 3:

Going up a ramp is a major problem. I believe this is because the character is trying to stabilize itself? (The character is simply the Roblox R15 Character welded onto a block (the skateboard)) I just don’t know what to do to fix that aside from making a custom character, which is more of an undertaking that I think I currently am able to do. So any advice on how to fix this would be greatly appreciated.
https://gyazo.com/c7206c78e730b6e49a13daef2123f560

3 Likes

Problem3: I’ve made a post above moving up slopes smoothly, there might be a way you can transfer this to your skateboard: Smooth Movement on Character? - #11 by goldenstein64

Problem2: You could try tweening down the force when the player lets go of a key to move. That way, it slows down smoothly and slowly.

1 Like

## Suggestion

For the first two problems you could possibly use some raycasting below the skateboard to check if it’s in unreal air time the air.

If the player is in the air, keep the constant velocity with the direction, while the torque force is adjusted while in the air. (in order to perform some sick 360s)

Ramp problems require another torque force to tilt the board up.

1 Like

I understand the concept of Raycasting (it’s like an arrow that comes out of the object & goes continuously in a direction until it hits something, right?) but have no understanding behind the implementation of it. Do I have to constantly call it?

The only thing with Raycasting on the DevHub is using a gun to make a bullet line, so it was confusing to me on how else to use it I suppose.

You do need to continuously fire it. To find if it has hit something, you use `game:findpartsonray()`. If this returns nil or an empty array (I can’t remember which ), then you know the player is in the air.

You will need to adjust the size of the Ray so that it detects the floor when on it, but detects nothing when jumping.

# Probable Problems

Pun not intended

Jumping over high objects

If you were to jump over an object which is just below the skateboard but not touching it, the raycast will most likely detect the part and keep you moving. This effect may be unnoticeable, but it may become an issue later on.

Timing

Your raycast will not be able to run constantly. Because if the expensiveness of a raycast and the gamescript timeout system, you will have to wait between each raycast. This is a problem, because you will always end up missing a second or two. If the player jumps in that time, you won’t get the slowdown effect.

You do have to call it frequently still because you need the returns of the callback to be different.

Raycasting is not expensive. You can fire off hundreds of rays per frame with no issue. Raycasting only becomes expensive once you start using single long raycasts.

Why would you have to “miss a second or two”? I don’t think raycasting is as expensive as that; you could comfortably raycast every frame without worrying, which is what a lot of people do to stabilize cars and a skateboard is still a moving “vehicle”, of sorts.

I’m also interested about game:findpartsonray(), I’ve never heard of that function.
How does this differ from workspace:FindPartsOnRay()/workspace:FindPartsOnRayWithIgnoreList()/workspace:FindPartsOnRayWithWhitelist()? Does it have any advantages?

OP, perhaps take a look at this thread (Car Suspension (Scripted)) - it is about cars but apparently they are using all BodyMovers and the wheels are just added on afterwards for effect. Maybe it could be of use!

I have this skateboard controller for a game I cancelled, if you are interested in getting the game source (for free) or a breakdown then dm me, we can talk this over.
streamable…com/f0m70 (its a clip, remove 2nd dot because i dont know how to stop it from embedding lol)

4 Likes

I think you may have misread what I said. I said that you do
need to continuously fire.

What about the gamescript timeout system? Will the script not timeout if you’re constantly firing a raycast?

I’m not sure what “gamescript timeout system” you’re talking about, but rays don’t yield threads. FindPartOnRay is an asynchronous call.

In regards to the timeout I was talking about, I was referring to this:

I believe this happens when a script runs for more than 20 seconds (10 in studio) without yielding. That’s what I was talking about when I suggested waiting between raycast calls (as they have to be constant, so therefore in a loop).

However, as I write this, it occurred to me that it would probably be a better solution to attach this to the heartbeat rather than using a loop. That way, it runs constantly without an infinite loop, and the timeout is avoided.