Data Realms Fan Forums
http://45.55.195.193/

Raycast Vehicles
http://45.55.195.193/viewtopic.php?f=73&t=14505
Page 1 of 2

Author:  zalo [ Tue May 05, 2009 6:02 am ]
Post subject:  Raycast Vehicles

So. Cortex Command does not support wheel joints, I'll give you that.
But most good car games don't use physically simulated wheels as "wheels".

A lot of games use Raycast wheels. It's where you cast a ray downward where the wheel
should be, and it pushes upward in that spot. The force it pushes upward is dependant on
how far the ray has to go before it touches anything.

Advantages:
1) Fast.
2) Suspension.
3) Fairly Simple to implement.
4) It would work very well on CC's bumpy enviroments.

Cons:
1) Doesn't fit into CC's whole physics based style (but it wouldn't
work that well if there were physical wheels anyway, because of
bumpy terrain.)
2) Wheels spinning would look odd.
3) May not deform terrain realistically.

Now, a while ago, Tim posted some code that went something like "SceneMan:MovePointToGround();".
Now if you had a Lua code that would detect the position of an attachable on a "vehicle"
and then move the point down from that attachable's position, and subtract the two to get
the distance of a "Ray", and the force that it would have to push up on that attachable,
you could theoretically make a raycast vehicle.

But, there are uncertainties.
1) Can you apply force to an attachable and have it affect the parent object?
2) Can Lua look out for attachables that are parented to another object?

Also, the matter of the wheel asthetics, where ever the ray hit the ground, would be
where the bottom of the wheel would be, up to a certain distance.

So, what do you think?

Author:  saltydog81 [ Tue May 05, 2009 6:20 am ]
Post subject:  Re: Raycast Vehicles

wouldn't using Lua to make the wheels only use the spin animation when "stepping" work so it they only spin when you move <- -> ?
as for the terrain being deformed weird well if that's the case maybe if the wheel uses a weak dig (weak enough to only effect terrain) that is in a straight line relative to the angle of the body

i can't think of any possible work around for the physics
i don't know if any of those would work but hopefully it helped

Author:  numgun [ Tue May 05, 2009 8:56 am ]
Post subject:  Re: Raycast Vehicles

zalo wrote:
So, what do you think?


Elastomania on CC :grin:

Hell, if we could get a small jeep to drive in CC, it would totally do some revolution.
Maybe some code to make it require an actor to run and have an "eject" feature.

Also for that question #1, I think it is infact possible. There was this function I saw in the Lua function dump... lemme see...

Ah here:

Code:
PRINT:     AddForce  function
PRINT:     SetWhichMOToNotHit  function
PRINT:     AddImpulseForce  function
PRINT:     AddAbsForce  function
PRINT:     Clone  function
PRINT:     AddAbsImpulseForce  function
PRINT:     ClearForces  function
PRINT:     ClearImpulseForces  function


Found them here: http://pastebin.com/f252ef35f

So think it will be possible. No idea about the second question though.

Author:  Geti [ Tue May 05, 2009 9:40 am ]
Post subject:  Re: Raycast Vehicles

also, to add to the fairly cirtain "yes" for the first question, the JointStiffness of an attachable determines how much of the impulse is transferred to the MO it is attached to.
it sounds possible, which is great. i am more interested in rope physics as of now, but this sounds more plausible with lua :P

Author:  Flammablezombie [ Tue May 05, 2009 7:09 pm ]
Post subject:  Re: Raycast Vehicles

saltydog81 wrote:
wouldn't using Lua to make the wheels only use the spin animation when "stepping" work so it they only spin when you move <- -> ?

That can be done already. Make the wheels part of the body, make the legs invisible, and set the bodies spriteanimmode to 4.

Author:  Azukki [ Wed May 06, 2009 2:01 am ]
Post subject:  Re: Raycast Vehicles

Flammablezombie wrote:
saltydog81 wrote:
wouldn't using Lua to make the wheels only use the spin animation when "stepping" work so it they only spin when you move <- -> ?

That can be done already. Make the wheels part of the body, make the legs invisible, and set the bodies spriteanimmode to 4.

The wheels can just be made as the legs and they look as if they rotate, as long as you've got rotational symmetry and a custom walkpath to make use of that rotsym.

However I got quite the negative reaction when I made legs looks like wheels on my jeep. Looking back, I know the mod didn't deserve praise because of it's terrible gibbing and whatever, but people seemed almost angry about my faking wheels, even when I never claimed that they were actual wheels. I think Thor called it a 'cop out', even when 'illusion' was in the title. To this day I still am baffled by the reaction.



Anyways, I've always wondered how games regularly went about wheels, that's fascinating. The idea seems fairly reasonable for implementation into CC. But I don't really understand how it would handle the slopes of a varying pixel terrain. Would it find the surface heights of each pixel in an area around it and calculate the slope of the line of best fit, or something like that? Could it ignore grass and ashes and whatever similar materials? Could the wheel collide regularly with MOs? Could the ray be cast in directions other than down, for when Gs of acceleration affect it? Could the rotational force be converted to force in the direction of the calculated slope based on the 'traction' that is the ray's shortness? Could gravity and the slope and the rotational force all be considered to cause proper coasting? For the sake of complete unbalance would you want to use Actors, (most basic actors, such as brains) or would you want to use a rocket so you could include a passenger system? Would you be able to negate the auto scuttle on the rocket if you used it? How would you go about all of this?

Just throwing things out there to be considered and thought about. Best of luck to anyone who will be attempting this. It's a good idea and could have great results, if someone has the ambition enough to do it.

Author:  zalo [ Wed May 06, 2009 3:59 am ]
Post subject:  Re: Raycast Vehicles

Code:
CastMaterialRay  function
CastMORay  function
CastObstacleRay  function
MovePointToGround  function
CastObstacleRay  function


Look's like Data's got ray casting in the bag, if that Lua list is anything to go by.

Also, I was also baffled by your jeep mod's reaction. I thought it worked fairly well.

Author:  numgun [ Wed May 06, 2009 10:35 am ]
Post subject:  Re: Raycast Vehicles

What jeep?

I barely remember something like a jeep wayyy long ago.
Was it the large one with lots of attachables and two soldiers on it?

I have no idea why the people acted like that back then.
Most likely a global "asshole-mode" was on at the time. : /

Author:  Azukki [ Wed May 06, 2009 12:37 pm ]
Post subject:  Re: Raycast Vehicles

numgun wrote:
What jeep?

I barely remember something like a jeep wayyy long ago.
Was it the large one with lots of attachables and two soldiers on it?

I have no idea why the people acted like that back then.
Most likely a global "asshole-mode" was on at the time. : /

Yeah, there's been two jeeps, mine was the one shortly after B19, with the coalition scaled size and the sloppy attachables and gibs. I'm not sure if there were two soldiers, I think there was just the driver and a little turret on the hood. There was a destroyable crate with something in it in the back... It really was awful, I'll admit, but the wheel's function and spinning appearance was the good part, and it was the subject of complaint, and that's the part that I never understood.

Author:  411570N3 [ Wed May 06, 2009 1:20 pm ]
Post subject:  Re: Raycast Vehicles

This sounds like a good idea, but I think there'd be some initial buggyness the first time someone tries...
Of course a good, extensive code using this method should work wonderfully.

Author:  Daman [ Fri May 08, 2009 1:04 am ]
Post subject:  Re: Raycast Vehicles

Then there's just the whole matter of waiting for lua in actors.

Author:  robowurmz [ Sat May 16, 2009 9:52 pm ]
Post subject:  Re: Raycast Vehicles

Daman wrote:
Then there's just the whole matter of waiting for lua in actors.

Doesn't Lua exist in actors already? For example, the Medic Drone?

Author:  Grif [ Sat May 16, 2009 10:18 pm ]
Post subject:  Re: Raycast Vehicles

robowurmz wrote:
Doesn't Lua exist in actors already? For example, the Medic Drone?


Protip: that post was made before b23 was released.

Author:  striker121 [ Sun May 17, 2009 1:30 am ]
Post subject:  Re: Raycast Vehicles

So is anyone coding this yet? Or are we just going to wait and be surprised? Also, thanks Zalo for that information. Its cool to know how they get various things working.

Author:  Daman [ Sun May 17, 2009 1:53 am ]
Post subject:  Re: Raycast Vehicles

striker121 wrote:
So is anyone coding this yet? Or are we just going to wait and be surprised? Also, thanks Zalo for that information. Its cool to know how they get various things working.


pretty sure you can't run lua on attachables, although I think he's almost got it done and is just using offsets.

He's probably just using applyabsforce on the actor

Page 1 of 2 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/