 # Wheel grip hax

Lawliet and I were fucking around with crawlers, I had just edited his wheel chip to use applefarce, then this idea sprung up…

``````           it's very simple. it's kind of cheating, but can be useful.
``````

here’s the chip I worked on for 4 wheel (or spindle) downforce.

``````
@name 4 Wheel Grip Hacks
@inputs On [R1 R2 L1 L2]:entity
@persist Force:vector
@persist DownF DownFrear
@trigger all
interval(20)
if(first())
#Adjust this to increase downforce on the front and rear wheels
{
DownF = -50
DownFrear = -50
}
Force = vec()
if(clk())
{
Force = Force + entity():up() * L1:mass() * DownF * On
Force = Force + entity():up() * L2:mass() * DownFrear * On
Force = Force + entity():up() * R1:mass() * DownF * On
Force = Force + entity():up() * R2:mass() * DownFrear * On
}

if(clk())
{
L1:applyForce(Force)
L2:applyForce(Force)
R1:applyForce(Force)
R2:applyForce(Force)
}

``````

just place it on your base and link it up, just make sure the chip is facing upwards, direction doesn’t matter.

almost like magnetic wheels That’s pretty fucking sweet. I need to make something similar.

Is there some reason this wouldn’t work with vector thrusters?

just some downwards force should do the trick

yeah, any downward force. my shit just applied downward force regardless of the props angle since it works on the chassis entity. if you make spoilers and use fin, downforce will actually aid cornering.

Couldn’t you apply it on the down angle of the axles? So it’ll be even more precise. Instead of one down angle it’ll have 3. Don’t know if it will do much difference but yeah.

I did this on a tank chassis a while ago, wrote like 200 lines of code to make it handle nicely, but it never really behaved how I wanted it to

As an added bonus, turn the car upside down and you’ve got a rocket!

You should add a check so it doesn’t apply the force if there is nothing below it (ranger), or if the downwards normal vector’s z component is bigger than 0 (it’s pointing upwards, or horizontally)

Alternatively you could decrease the downwards force if the second is true, to allow for bumpier and steeper slopes.

place the chip on the axle itself

[editline]12:24AM[/editline]

i’ll learn a little more about internal gyroscopes, but for now, here’s a ranger check.

``````

@name 4 Wheel Grip Hacks
@inputs On [R1 R2 L1 L2]:entity Ranger
@persist Force:vector
@persist DownF DownFrear
@trigger all
interval(20)
if(first())
#Adjust this to increase downforce on the front and rear wheels
{
DownF = -50
DownFrear = -50
}
Force = vec()
if(Ranger > 30)
{
if(clk())
{
Force = Force + entity():up() * L1:mass() * DownF * On
Force = Force + entity():up() * L2:mass() * DownFrear * On
Force = Force + entity():up() * R1:mass() * DownF * On
Force = Force + entity():up() * R2:mass() * DownFrear * On
}
}

if(clk())
{
L1:applyForce(Force)
L2:applyForce(Force)
R1:applyForce(Force)
R2:applyForce(Force)
}

``````
``````
Limit = 90
if(abs(entity():angles():pitch()) <= Limit & abs(entity():angles():roll()) <= Limit)

``````

That should suffice for an angle-based solution, reduce Limit to reduce how far the hax works on tilt, based on the angles of the E2 chip.

``````
@persist E:entity Limit

if(first()){
E=entity()
rangerPersist(1)
rangerFilter(E:getConstraints())
rangerFilter(E)

Limit = 90
}

Ranger = rangerOffset(30,E:pos(),-E:up()):hit()
Ang = E:angles()
Pitch = abs(Ang:pitch())
Roll = abs(Ang:roll())
if(Ranger & Pitch <= Limit & Roll <= Limit){
#do stuff#
}

``````

This ought to work alright for a combined approach. Since we can limit the distance of the E2 ranger, we only need to know if it hit anything out to our max distance, so :hit() suffices over :distance() here.

A much easier and safer check to see if the object is pointing downwards is to do this:

``````
if( Entity:up():z() < 0 ) {
# If a direction going out from the top of our prop's z-component is negative, that means that the prop is tilted 90 or more degrees in some direction.
}

``````

True, but it has far less control than using angles, which would allow you to set specifically how far overturned the vehicle can be, meaning you could let it drive up walls or flounder on a small incline.

I’ll bump this cause nothing goes on here anyways but
K why not use a thruster with a ranger below it?.. instead of 200 lines of code. I’ve made quite a few anti-gravity car things a looong time ago like this with no spazzes.
I actually want to know the difference lol

It forces the wheels downwards so it doesn’t compress the suspension

But they were used on the wheels… The thrusters were ball socketed inside the wheels and adv. ballsocketed to the frame so they always face downward

200 lines of code? i don’t even think it breaches 30

/care

Just because you might think that code is complicated, we don’t

haha good to know hunta. don’t get your helmet in a bunch
Just wanted to know if I’ve already done this correctly a while ago

In my humble opinion. writing 30 lines of e2 is easier than wiring up a thruster with all those gates :downs: