Cog Quiz

Week 7 - Answer

Prev - Exit - Next

Show Quiz

Level 1

In order for a projectile to change its velocity towards a target, following commands do the work.

While SetThingVel() slows down as it gets closer to the target by entering its own position and target position to set its velocity.

   SetThingVel(projectile, VectorSub(GetThingPos(victim), GetThingPos(projectile)));

So this was not a good idea to change the whole velocity of it. Now ApplyForce() will only apply a certain power of force to the velocity of the projectile.

Thinking it logically, missiles changing directions in real world should boost the engine towards another direction, which means adding a new vector to a different direction.

   ApplyForce(projectile, VectorScale(VectorSub(GetThingPos(victim), GetThingPos(projectile)), Flex));

Pushes the projectile towards the victim with the power of "Flex".


Level 2

To search something in front of it, it's already done. The force cogs! Take a look at force_throw.cog for example. In the pulse message it has all the codes needed to search targets in front of something. Just do the same for this seeker as well.


Level 3

As the facts are gathered, it shouldn't be too hard to write up the cog, first of all, it needs to start searching as the projectile gets created.

- Place a created message and since you can fire multiple projectiles at once rather use SetThingPulse(projectile, 0.05);.

- Retrieve the projectile by using GetSenderRef() in pulse message, so it won't be confused with other seekers fired soon.

- Place the searching codes in the pulse section.

- When the victim is found, place the script that changes the direction of the projectile.

That's all.