How can I detect obstacles in a game, for example, when a tank moves in a certain direction? And can be bypassed?
I remember this question on csdn. Did not take a closer look.
The simplest idea: In each exercise time unit, such as 0.1 seconds. To see if there are any obstacles to moving to the location.
There are two disadvantages: the calculation workload is relatively large & the tank is silly, not hitting the south wall and not looking back.
There is a restriction that the tank has its own visible range.
If players define their own tanks. To define unitprofileattribute {
Cost = 300; // cost
Speed = 3; // mobile intensity
Power = 3; // firepower
Powerspeed = 5; // shell speed
Defense = 100; // armor
Reloadtime = 10; // Interval
Radarrange = 100; // the performance of the above Tanks must be tested. Not worth the money
Override angle onstep (Unit me) {// the angle from which to move each time
// Look at the radar and choose to go left and right.
// You have to decide to open the fire when you discover the enemy.
}
}
This is the information unit {
Point Target; // move the target
Scaninfo radar; // Radar Information
Shot (); // fired
}
If you are interested, think about how to find the path. By default, the system may provide a stupid tank that turns left into a wall.
This very earthy framework is under construction, hoping to help ourgame.