About Store Forum Documentation Contact



Post Reply 
Looking into player
Author Message
Ogniok Offline
Member

Post: #1
Looking into player
Hi!

How can I set Game::Chr in my game looking into player?

(Polish: Jak mogę ustawić postać przeciwnika w mojej grze, by patrzył się twarzą na mnie?)
03-17-2010 08:27 PM
Find all posts by this user Quote this message in a reply
Barthap Offline
Member

Post: #2
RE: Looking into player
AI from Bloody Massacre can help you
Code:
// if in attack range then rotate to face the target
if(in_range)
               {
                  actionBreak(); // stop moving any further

                  Flt angle_delta    =AngleDelta(angle.x+PI_2, Angle(target().pos().xz() - pos().xz())), // calculate angle delta between current look angle and target angle
                      max_frame_delta=Tm.d()*DegToRad(270); // 270 degrees per second, this is the maximum angle delta limit to change per frame

                  Clamp(angle_delta, -max_frame_delta, max_frame_delta);
                  angle.x+=angle_delta;
               }
It is a small part of code AI::update()

And checking if player is near AI and if it is looking at player
Code:
void AI::hit()
{
   Vec dir; SinCos(dir.z,dir.x,angle.x+PI_2); dir.y=0; // get AI looking direction

   // check all the players
   REPA(Players)
   {
      Player &plr=Players[i];
      if(inAttackRange(plr))
         if(AbsAngleBetween(dir,plr.pos()-pos())<=PI_3) // 60 degrees
            plr.addDamage(RandomF(5,8),this);
   }
}
(This post was last modified: 03-17-2010 08:42 PM by Barthap.)
03-17-2010 08:35 PM
Find all posts by this user Quote this message in a reply
Koniu Offline
Member

Post: #3
RE: Looking into player
AI w bloody Massacre, fakt może pomóc, ale tam przeciwnik był ustawiony do nas twarzą dopiero wtedy, gdy do nas biegł. Przy odrobinie roboty, usuniesz to że do Ciebie podbiegał i atakował, a wtedy osiągniesz oczekiwany efekt.
03-17-2010 08:42 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #4
RE: Looking into player
It will be good if you could write everything in English, cause there are many users not from Poland, and this threads could be useful for them too.
(This post was last modified: 03-17-2010 09:04 PM by Harry.)
03-17-2010 09:03 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Barthap Offline
Member

Post: #5
RE: Looking into player
We all are from Poland pfft
03-17-2010 09:07 PM
Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #6
RE: Looking into player
No ale mówię o tych innych, którzy nie są z Polski. Może znaleźliby tu odpowiedzi na swoje pytania itp, a tak to się robi taki bałagan językowy wink
03-17-2010 09:08 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #7
RE: Looking into player
I have this code:

Code:
Flt angle_delta = AngleDelta(this->angle.x + PI_2, Angle(Players[0].pos().xz() - this->pos().xz()));
            Flt max_frame_delta = Time.d() * DegToRad(270);

            Clamp(angle_delta, -max_frame_delta, max_frame_delta);
            this->angle.x += angle_delta;

but it don't do what i expected. It doesn't face player direction!
03-17-2010 09:09 PM
Find all posts by this user Quote this message in a reply
Barthap Offline
Member

Post: #8
RE: Looking into player
Harry Wrote:No ale mówię o tych innych, którzy nie są z Polski. Może znaleźliby tu odpowiedzi na swoje pytania itp, a tak to się robi taki bałagan językowy
So don't speak Polish. I wanted to say: all users who write in this theard are from Poland
03-17-2010 09:11 PM
Find all posts by this user Quote this message in a reply
Koniu Offline
Member

Post: #9
RE: Looking into player
Harry, on this forum there are many members from Poland. I just did not helped too much, so I think there is no problem smile

And I am weak in English grin
If the thread talking only Polish user, why not write in Polish? : D
(This post was last modified: 03-17-2010 09:13 PM by Koniu.)
03-17-2010 09:11 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Barthap Offline
Member

Post: #10
RE: Looking into player
Why? Becouse not only Polish users can help him. But stop this offtop, this is engine support!
03-17-2010 09:17 PM
Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #11
RE: Looking into player
So, tell me what I'm doing wrong and what do i have to do?
03-17-2010 09:19 PM
Find all posts by this user Quote this message in a reply
Koniu Offline
Member

Post: #12
RE: Looking into player
Polish members also receive support, what if someone does not know how English?
03-17-2010 09:20 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Barthap Offline
Member

Post: #13
RE: Looking into player
don't continue this offtop here, I can tell you: to game development people must know English basics, but if first post in theard is polish you can speak polish but here is english and polish so you can help him in English.

@Ogniok: Sorry, I don't know what is wrong in your code :(
03-17-2010 09:27 PM
Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #14
RE: Looking into player
It's alright now. It works perfectly.
03-17-2010 09:30 PM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #15
RE: Looking into player
So maybe tell us, what did you do?
It could help others to solve a similar problem.
03-17-2010 10:02 PM
Find all posts by this user Quote this message in a reply
Post Reply