terrain deformation.. sort of

This forum is currently in read-only mode.
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • hi everyone! new user here. well not entirely new, ive been using construct classic for a few months now and downloaded a lot of tutorials and even made some simple stuff already.

    i wanted to start a little discussion about a few issues im having. first of all, im really fascinated by all kinds of different, not very used technologies in games, and mainly im talking about terrain deformation in this post. anyone who has played sega rally revo or mx vs atv: reflex knows what im implying.

    in sega rally it was subtly used, but it did impact handling in some situations, and frankly, the game would have been pretty standard/mediocre without that tech. but it really made the game a little more enjoyable.

    reflex took this a bit further, because you were able to really mold the terrain with your tires. you could make little hills and bumps even and i remember spending alot of time just fooling around and marvelling the tech behind it.

    now, im not hoping to make anything near that quality in construct, BUT.

    it got me thinking if something similar would be possible in a top down racing game. maybe some prebaked, smoke and mirrors style effects.

    okay, so ive been testing stuff and the immediate first problem arises when considering skidmarks, or tire tracks, whatever you call them.

    im not really sure what would be the best method creating skidmarks? creating skidmark sprite(s) every x seconds while moving quickly drains resources, after a lap or two. i started thinking (from that destructible terraing example)that if i used a reasonably sized track and made it a canvas object, then erase effect, so that the skidmark sprite erases the canvas, shaping the track? i havent properly tried this but i wanted to ask if its even worth a try? or is it completely insane as an idea to begin with? ive heard the canvas object takes a lot of juice, so big racetracks are out of the question with that? maybe some small track like slicks n slides or generally- games for example?

    now the second issue of this could be a little simpler actually, just time consuming. simulating the skidmark, bump, traction effect. i thought originally that it would be something like so:

    -positioning 4 detector sprites at the place where the tires would be in the car sprites.

    -check collision when the detector collides/overlaps the skidmark or tire track.

    -make small subtle adjustments to car sprite's velocity/angle. (nudges,loss of skidding,traction boost etc.)

    one big challenge(as if those werent enough already) would be the actual car behavior. im not sure if i would use the car behav itself, because the collision behavior is, to say it bluntly, kind of primitive.

    so maybe i could use a physics object with custom made behavior using add force etc. that would make it easier to use the above mentioned adjustments to handling when traversing the terrain though.

    so i guess i wanted to hear you guys opinion, hints, maybe even get some discussion and prototypes for this project

    <img src="smileys/smiley1.gif" border="0" align="middle" />

    OR you could always just say to stop even trying because it has been tried 1000 times over <img src="smileys/smiley36.gif" border="0" align="middle" />

    anyway, thanks for atleast reading this poorly excuted novel of a thread, hope theres atleast someone who could help <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • For the visual portion (skids and such) the canvas object is the way to go. It takes as much space as you'd expect a large image to take so it may use a lot of your vram, but whatever. If you find that the canvas is taking too much vram you can use a smaller canvas scaled up.

    For the terrain info (traction, height, etc...) I would use a large array the size of the track to store the info of each pixel or so.   It will likely be time consuming at runtime filling the array with the whole track info, but it only would need to be done at the start of the track then after that only what the cars are touching would get updated so it will be very fast. You could also use a smaller scaled array for the data to save on cpu time if needed.

    A google search for "2d car physics" yields some code for more realistic car physics. The only catch is it's in c++ but it's useful for gleaning the algorithm and math involved. The more appealing one takes the rotation speed and angle of the tires into consideration with fiction to the ground and applies a force to the car body.

  • hi rojo and thanks for replying!

    i think im gonna try te canvas stuff. do you have any guidelines as to how big of a canvas would be "optimal" or how big is going to be overkill? i have a pretty beasty computer so its always kind of difficult to keep track on how demanding my project will be lol.

    the array object is completely alien to me, havent really studied how it works, but i kind of get what you mean.i really have to study it and learn how to implement it,that would make it possible to have hills and bumps and stuff, good idea. but first i was thinking id focus on how the skidmarks affect your car,taking into account the angle,speed and stuff,when colliding with skidmarks.

    i did some tests with physics object, but theres already some stuff that makes my brains fart <img src="smileys/smiley36.gif" border="0" align="middle" />

    for example, i made it so that phys object has another object always set to an image point,so that when i push down up arrow i add force and the "car" mowes forward. turning and velocity is the problem. now the velocity works as if its a rocket. meaning that when im not pushing up arrow and turn, it doesnt move towards the angle anymore, because force is not added, instead you can just turn in place.so, the first obstacle lol. i could probably make a behavior,that when the car moves, it adds 1unit of force forwards,and if the the up arrow isnt pressed,it adds 2units in the opposite direction, to slow down while still having the momentum towards the right angle..? <img src="smileys/smiley4.gif" border="0" align="middle" /> or am i making any sense?

    i had another idea of making a compromise and using the car behav, but upon collision, i could somehow destroy the car and spawn a corresponding physics object that would handle the collision. i would need a way to determine the speed upon impact and store the value in order to use it for the physics object though.

    car physics are really difficult to make from scratch, considering all the physics calculations and math involved. sucks for me since i completely lock out when someone says "math"

    <img src="smileys/smiley36.gif" border="0" align="middle" />

    EDIT: thanks for the cap btw. just to make sure, is the scaling simply done by using the canvas:set height/width action? that seem pretty useful.

  • taking baby steps, but i managed to get a simple prototype real quick, if anyones interested:


    the canvas works just as i hoped and i even have a way to check collisions with the tire tracks, although everything is still very barebones and primitive.

    i got a few questions though:

    1. is there any way i could use the erase effect with a smaller magnitude. for example, while touching virgin track surface, only erase with 50% strength. when touching the same section again,erase all?

    and further, is there way to use gradient erase,just to get smoother edges for the tire tracks?

    2. as you can see from the .cap, there's still the issue with a little bit too much slide and being able to turn while not moving.

    i guess this would probably be simple to fix with a velocity check, but problem is, how do i determine the condition, when car is moving in any direction? do i have to check all the directions at once?

    for example

    car Xvelocity is greater than 1


    car Yvelocity is greater than 1


    car Xvelocity is less than -1


    car Yvelocity is less than -1

    is this correct? i mean im having problems to determine the fact that if the car is moving at all. but that condition list seems a little too complex, and i couldnt get it to work like that. when youre checking negative velocity, is it supposed to be less than -1 or greater than? i got a little confused by that <img src="smileys/smiley36.gif" border="0" align="middle">

    aside from that, i like the use of a physics object as a car, right now it has a great sense of weigth and even a bit of oversteering and with a little thought and fine tuning it could work really well, and the collision feels good.when i get that velocity check figured out, i can add over and understeering related to speed and all those fine details.

    so anyone got any helpful ideas? mainly that velocity thing is bothering me as of now.

  • continuing my monolog, i managed to get a somewhat working prototype for my racer, got a little distracted by lighting and shadows, so i decided to make a small example, if anyone is interested. spent almost the whole evening with learning how to do bump mapping and shadows. theres also a little bit of terrain effects, though just a brutally simple idea still.had to make a workaround for the velocity issue cause i still dont know how to determine it. also note that theres alot of plugins in use, so you may have to DL those. the event sheet is also a complete mess and im not surprised if it doesnt run well at all <img src="smileys/smiley36.gif" border="0" align="middle"> anyway, here it is:


    im still open for hints, tips and suggestions of all kinds!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)