(03-18-2016, 12:50 PM)tomaszkax86 Wrote: tar2.position is of type point, which has 3 floats. You need to save it to a variable and calculate position:
You might want to use object's orientation (angle) to calculate position using cos() and sin().
I'v got some positive results, thanks! The idea to calculte position of an object is quite interesting. Could you explain with some example, please, how to get angle of an object using cos and sin? For example, Target2?
(03-18-2016, 12:50 PM)tomaszkax86 Wrote: Side note: goto() is kinda like cheating. It's too easy. Try doing the same using motor() and jet(). I think this could be a good idea for a programming challenge. A speed run or something.
Yes, I'm inclined to agree with you. But I confronted with some troubles using move(). In previous mission my WheeledShooter every time, when was stopped by a building or ruin or a bot, continued to do move() without end. Though there was errmode() in the code. In the same time, errmode() worked correctly when WheeledShooter confronted with some plant. Why in one case the game didn't take stopping as an error and in other case took it as an error and performed errmode() that is a big riddle for me. Here is that code:
Code:
object ant, power;
point pos, pos2;
float lev = 0;
ant=radar(AlienAnt);
float dir = direction(ant.position);
while(true)
{
while(radar(AlienAnt, 0, 360, 0, 20) == null)
{
ant = radar(AlienAnt);
dir = direction(ant.position);
turn(dir);
errmode(0);
int err;
err = move(distance(position, ant.position)-40);
if ( err != 0 )
{
turn(90);
move(3);
}
if (distance(position, ant.position) < 50)
{
ant = radar(AlienAnt);
dir = direction(ant.position);
turn(dir);
aim(ant.position.z);
fire(1);
}
if (energyCell.energyLevel < 0.5)
break;
}
power = radar(PowerStation);
goto(power.position);
while(energyCell.energyLevel < 1)
wait(1);
}
}