• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Steering a car with a mouse

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
I'm working on a car game and I'd like to have a good steering system. The system I've been working on works by right-clicking roughly where you want to go, and your car will try to turn fast enough to go through that point. If you right-click too close, you'll spin out trying to turn faster than you can. It works like my Battle for Tatooine map (see my signature) did in WC3.

With SC2 though, I should be able to make a good mouse-based steering system that doesn't require you to constantly right-click every time you want to change directions. I've been having trouble figuring it out though. Has anyone done something like this before? I'm not asking for the programming code, just the idea.
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
You can use the UI - Mouse Moved event, but it generates intensive network traffic, and I'm not sure there is no lag attached to it (possibly unnoticed on the local machine, but becoming more obvious when playing over the net). Setup a trigger with this event, and depending on the (Triggering Player), you can perform some check-ups on mouse movements and see how you steer the car.

Normally the type of comparison you could do is related, let's say, to the variation in X coordinate from one moment (one run of the trigger's actions) to the next. The more the player moves the mouse to the right, the more you steer the car to the right, probably with some upper limit - similar with the left.

Experiment and let us know what you can come up with.
 
Ohhhh did you make physics in your map? My understanding of physics is pretty poor and there's still somethings I need to work out properly such as sliding and xybounce.

Can you upload your map so I can take a look at it? Here's mine: http://us.battle.net/sc2/en/forum/topic/4081808712

You can use the UI - Mouse Moved event, but it generates intensive network traffic, and I'm not sure there is no lag attached to it (possibly unnoticed on the local machine, but becoming more obvious when playing over the net). Setup a trigger with this event, and depending on the (Triggering Player), you can perform some check-ups on mouse movements and see how you steer the car.

Normally the type of comparison you could do is related, let's say, to the variation in X coordinate from one moment (one run of the trigger's actions) to the next. The more the player moves the mouse to the right, the more you steer the car to the right, probably with some upper limit - similar with the left.

Experiment and let us know what you can come up with.
There's a much better way to do that the guy who made the Diablo map did. It's odd that it would work so well but it does. http://www.youtube.com/watch?v=TWnu8VvAnAE
 
Level 14
Joined
Aug 30, 2004
Messages
909
Ohhhh did you make physics in your map? My understanding of physics is pretty poor and there's still somethings I need to work out properly such as sliding and xybounce.

Can you upload your map so I can take a look at it? Here's mine: http://us.battle.net/sc2/en/forum/topic/4081808712


There's a much better way to do that the guy who made the Diablo map did. It's odd that it would work so well but it does. http://www.youtube.com/watch?v=TWnu8VvAnAE

This is still in the early early stages, but I have some physics, like jumping, going faster down hills, slower up hills, spins out of control, traction, etc.

http://www.hiveworkshop.com/forums/pastebin_data/5c9ctj/_files/autodual 24.SC2Map

Press the W key to accelerate, S to slow down. Right click to turn, but that's what I want to change. Also, if you press S and right click in a direction (then release S quickly) you'll do a controlled skid and end up facing where you clicked while maintaining forward movement.


As for mouse-based movement, I guess I'll just have to experiment. I'm worried about using the left-right axis for steering because it would be counterintuitive when the car is moving down the screen. You'd have to move the mouse to the right in order to make a right turn, which would take the car to the left side of the screen. It might be okay, I don't know... I was thinking something like the system for rotating an object in Microsoft Windows. Where you grab the object and it turns based on where you move the mouse to, but I don't want to make the driver grab the car to turn it.

I'll play around and see.
 
This is still in the early early stages, but I have some physics, like jumping, going faster down hills, slower up hills, spins out of control, traction, etc.

http://www.hiveworkshop.com/forums/pastebin_data/5c9ctj/_files/autodual 24.SC2Map

Press the W key to accelerate, S to slow down. Right click to turn, but that's what I want to change. Also, if you press S and right click in a direction (then release S quickly) you'll do a controlled skid and end up facing where you clicked while maintaining forward movement.


As for mouse-based movement, I guess I'll just have to experiment. I'm worried about using the left-right axis for steering because it would be counterintuitive when the car is moving down the screen. You'd have to move the mouse to the right in order to make a right turn, which would take the car to the left side of the screen. It might be okay, I don't know... I was thinking something like the system for rotating an object in Microsoft Windows. Where you grab the object and it turns based on where you move the mouse to, but I don't want to make the driver grab the car to turn it.

I'll play around and see.

>going faster down hills, slower up hills,

Do they slide down hills when not in motion? That's what I'm looking for. Opening your map up in my editor now.

Edit: Holy crap this sucks. You might as well use my incomplete physics system. You mind leaving a comment here to bump this thread so it gets feedback? http://us.battle.net/sc2/en/forum/topic/4081808712

You can DL the map too and see what I've done so far.
 
Level 14
Joined
Aug 30, 2004
Messages
909


Edit: Holy crap this sucks. You might as well use my incomplete physics system. You mind leaving a comment here to bump this thread so it gets feedback? http://us.battle.net/sc2/en/forum/topic/4081808712

[/COLOR]

Well that's rude!

Your system makes no sense to me, and I tend to make things from scratch so I know what to modify. Trying to integrate other people's systems is a nightmare.

A car will roll downhill but only if the wheels are pointed in that direction...so if you're on your side you won't slip down, but if you drive up a hill you will roll back down.
 
Well that's rude!

Your system makes no sense to me, and I tend to make things from scratch so I know what to modify. Trying to integrate other people's systems is a nightmare.

A car will roll downhill but only if the wheels are pointed in that direction...so if you're on your side you won't slip down, but if you drive up a hill you will roll back down.
My map is in a terrible state too right now... not done making every kind of physics behaviour yet x.x

You mind bumping that thread though I need feedback and don't understand how to do xy-part of bouncing off of terrain.
 
Level 14
Joined
Aug 30, 2004
Messages
909
My map is in a terrible state too right now... not done making every kind of physics behaviour yet x.x

You mind bumping that thread though I need feedback and don't understand how to do xy-part of bouncing off of terrain.

I've given some thought to that problem myself. I don't want cars bouncing off of walls really, I want them crashing into it and then skidding along the wall in the closest direction they can. I have a version of that working in the map actually, but it's not perfect yet. Basically, drive parallel to a wall and then gently turn into it...you're car will hit the wall and then continue driving parallel.

The problem with bouncing and with collision into a wall is that we need to know the formula for the line of the wall or the thing you're bouncing off of. Imagine your object is flying from east to west...it makes a difference if it hits a north-south line (in which case it will bounce back the way it came) or if it hits a line that stretches from northwest to southeast, in which case the ball will bounce north.

So far the only way I've had to find out what line the car is colliding with is to detect the collision, then check the height of the terrain all around the car to determine when the height of the terrain drops below some critical threshold (forgot what I picked).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
If you turned on wireframe mode to see...
They are exactly 1 unit appart alligned at all integers that make up the field. All tiles are broken into triangles with hypotenuse running from lower left to upper right.

The normal of the triangle is the vector that intesects the triangle perpendicually (90 degrees from the face of the triangle).
 
Status
Not open for further replies.
Top