![]() |
Onwaal
Can someone PLEASE help me with the onwall checks for a car? :C
I SUCK at onwall checks, I'm just doing PHP Code:
I'm showing an image for the car, which simply rotates. |
The difficult part is detecting where it hits the car and calculating how the car should react (e.g. bounce off or come to a complete stop or just slow down but continue moving or whatever) depending on the angle it hits and the speed it's travelling.
Unless the car is small, using the X/Y co-ordinates will not work because probably that part of the car is not on the wall. You need to detect ahead of the direction the car is moving and for the width of the car, or do multiple checks. |
Depends, is your car only moving in four directions or is it capable of turning in a complete circle?
|
Actually I have some code similar to what you're doing.
This was for an NPC: PHP Code:
It was actually a line follower which I tried (without success :P ) to develop into a maze solver. The line follower code may actually help as a base for deciding what should happen depending on which 'sensor' has been hit. PHP Code:
|
The key is to check the next possible movement, ahead of the NPC, as the 'current' placement of the NPC will usually be behind in consideration with the movement.
Also, if you have the car turning, what I did was do multiple checks along the front of the car, from say, the left bumper to the right. If there is any check that is onwall, stop the movement. |
Yeah, but just stopping will feel incredibly strange to anyone driving the car (depending on speed). If you drive 100mph into a wall at anything but head on you wouldn't just stop
Look at my crudely drawn attachment ;) Depending on the angle, the car will hit the wall and go front first into the wall (A) or the corner will slide along the wall and the left side of the car will get closer to the wall (B). |
I'll just post my code... JKWhoSaysNi, thanks, but that won't work with full angles (I think?)
PHP Code:
|
Quote:
|
Quote:
What's wrong with it at the moment? |
Get on Tales and try it ... The server Tales, I'm on now. You can see for yourself.
|
onwall2() might have been fixed up a little better but otherwise, I suggest onwall() personnally as I have always found it to be way more accurate in my wall checks.
|
HTML Code:
function getMove(playersPosition) |
Quote:
|
Quote:
|
Quote:
For car movement it can be better to use onwall() though, since you need to do several checks to detect how you are touching the wall. It is especially quite some work to detect diagonal walls like on Zone, it is working most of the time but when the bike is fast it is getting harder since doing pixel-accurate checks on the whole shape of the bike is too slow. |
Quote:
|
Hmm, it would be cool if stefan made an onwall check public function. (release in gscript -- not hard-coded)
EX: PHP Code:
|
Quote:
|
Please post the code! I love you <3
|
Quote:
I use loriel's check, it works fine but too fast makes it so you can't go close to the wall =[ |
Quote:
|
Quote:
|
Quote:
I don't do it that simple though, I have it do a do-while loop which moves the player every single tile. It seems to be the most effecient way. |
Quote:
Quote:
|
Quote:
I'll post it in the code gallery and link it from here a little later after I spice it up (gotta remove some server specific things from the function first) |
Quote:
|
| All times are GMT +2. The time now is 05:11 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.