|
-
incredibulus-actionscriptum
car hit??
ok guys look at this image

the question is how do i make the red mc which is inside the car(rectangles) mc rotate in a way that its always hitting the walls?
this way (i think) the car hitTest should be more accurate and it will require only one inner mc assuming you dont reverse
any idea codewise???
thanks
-
If you're trying to do what i *think* you're trying to do... I do that with 4 red mc's inside the rectangle and no code at all
If the car is moving forward (not sliding) you probably only need to check 2 of the 4.
-
ism
did you want this to work only within the square shape or can the walls be any angle??
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Senior Member
http://www.flashkit.com/board/attach...postid=2356227
http://www.flashkit.com/board/showth...hreadid=446301
Hittest against all four points using a loop or compare the _x,_y coords against your tilebased engine - then adjust velocity accordingly. I used something simialir in my old GTA engine...
fracture2 - the sequel
fracture - retro shooter
blog - games, design and the rest
"2D is a format, not a limitation" -Luis Barriga
-
incredibulus-actionscriptum
Originally posted by BlinkOk
did you want this to work only within the square shape or can the walls be any angle??
yes blink if the red hit detection mc moves within the car according to its rotation i believe that no matter how the background is it should work for straight and angled walls "i think"
maybe i might have to add another mc in the back but for now i wannna try with one i just cant seem to translate to code
the idea of having 4 mc inside the car its ok but i am trying to optimize the all thing by having only one hit check
perhaps i am way off am i ?
thanks guys
-
ism
as long as the car is going forward! although you could just reverse the test if it's going backward.
give me a little while to think about it. i reckon you're right!
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
ism
i think you could prolly reduce it to one test but i'm still workin on the math. however mabey the math for that would make it not worthwhile so anyway here's the two point check.
1. you need to take into account the direction of travel. if your going forward the the leading two corners are going to hit.
2. if your going backward then the trailing to corners are going to hit.
3. you can check for a hit by x = car._width / 2 and y = car._height / 2. assuming the cars initial position is facing upwards then the leading right will be p = { x: x, y: y * -1) and the leading left will be p = { x: x * -1, y: y * -1 }. if you use car.localToGlobal(p) and walls.globalToLocal(p) then you can check if Math.abs(p.x) > walls._width / 2 or Math.abs(p.y) > walls._height / 2 to determine if the car has collided with the walls. p will also be the point of collision. If your going backward then the y * -1 becomes just y.
No hittests!! have a think about it and i'll see if i can make a .fla.
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
ism
this is the code. i added a proximity test up front so if the car was nowhere near the wall it wouldn't go into the point testing.
http://www.nlc.net.au/~oceana/games/carWalls.swf
http://www.nlc.net.au/~oceana/games/carWalls.zip
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
incredibulus-actionscriptum
thats veeeery cool blink i havent looked at the code yet thuogh
the way i was trying to do it was with the red dot inside the car
which in a actual game you make it invisible
but your way looks cool
anyway i gonna take a look at the code now......
thanks blink you'r da man
-
Senior Member
Why ignore my answer? It may be tricky trigonometry but it works.
fracture2 - the sequel
fracture - retro shooter
blog - games, design and the rest
"2D is a format, not a limitation" -Luis Barriga
-
ism
i not 100% sure but i think the 4 point hit test is a little slow and most importantly he needs the point of impact. if i know magnetos he's workin on some car collision physics.
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
incredibulus-actionscriptum
blink is right !!
sorry random if it seemd like i ignored your answer but i didnt infact i did dowload the fla and took a look at it
thanks random
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|