View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:47 pm



Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
 Raycast Vehicles 
Author Message

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post 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?


Tue May 05, 2009 6:02 am
Profile WWW
User avatar

Joined: Sat Apr 11, 2009 6:28 am
Posts: 99
Location: Whidbey Island, Wa
Reply with quote
Post 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


Tue May 05, 2009 6:20 am
Profile

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post 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.


Tue May 05, 2009 8:56 am
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post 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


Tue May 05, 2009 9:40 am
Profile WWW
User avatar

Joined: Wed Jan 14, 2009 7:12 pm
Posts: 1525
Location: In between your sister's legs, showing her how to use a... PS3 controller!
Reply with quote
Post 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.


Tue May 05, 2009 7:09 pm
Profile
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post 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.


Wed May 06, 2009 2:01 am
Profile

Joined: Sat Feb 03, 2007 7:11 pm
Posts: 1496
Reply with quote
Post 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.


Wed May 06, 2009 3:59 am
Profile WWW

Joined: Sat Jan 13, 2007 11:04 pm
Posts: 2932
Reply with quote
Post 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. : /


Wed May 06, 2009 10:35 am
Profile
User avatar

Joined: Sat Nov 03, 2007 9:44 pm
Posts: 1916
Location: Flint Hills
Reply with quote
Post 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.


Wed May 06, 2009 12:37 pm
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post 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.


Wed May 06, 2009 1:20 pm
Profile WWW
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post Re: Raycast Vehicles
Then there's just the whole matter of waiting for lua in actors.


Fri May 08, 2009 1:04 am
Profile

Joined: Thu Aug 16, 2007 10:09 am
Posts: 163
Reply with quote
Post 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?


Sat May 16, 2009 9:52 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Sat May 16, 2009 10:18 pm
Profile
User avatar

Joined: Tue Jul 03, 2007 10:24 pm
Posts: 253
Location: In the house next door, eating your neighbors.
Reply with quote
Post 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.


Sun May 17, 2009 1:30 am
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post 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


Sun May 17, 2009 1:53 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 18 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.284s | 13 Queries | GZIP : Off ]