Hallo,
ich möchte in meinem Spiel mit der c_trace-Funktion Schüsse simulieren. Dazu nutzte ich das SHOOT-Event bei den Gegnerentitys. Doch irgendwie werden die Entitys gar nicht vom c_trace erkannt. Der "Strahl" geht definitiv durch die Boundingbox der Entitys hindurch. Ich denke, dass die Kollisionserkennung bei den Entitys gar nicht aktiv ist. Hab schon vieles versucht, aber nie wird eine Kollision erkannt. Hier ist eine gekürzte main.c:
---------------------------------------------
Hello,
in my game I want to simulate shots with the c_trace function. Therefore the enemy entities make use of the SHOOT-event. But somehow the entities arn't recognized by the c_trace. The trace definitely crosses the bounding box of the entities. I think that the collision detection of the entities is somehow disabled. I've tried a lot, but a collision was never detected. Here is the reduced main.c:
Code:
#include <acknex.h>
#include <default.c>

var bShootEnable = false;

function shoot();
function warlockHit();
action warlock();

function main()
{
   mouse_mode = 3;
   level_load(NULL);
   ent_create("warlock.mdl",vector(150,0,0),warlock);
   while(1)
   {
      if(mouse_left)
         shoot();
      wait(1);
   }
   return 0;   
}

action warlock()
{
   reset(me,PASSABLE);
   c_setminmax(me);
   my.emask |= ENABLE_SHOOT;
   my.event = warlockHit;   
}

function warlockHit()
{
   if(event_type == EVENT_SHOOT)
   {
      printf("Getroffen");   
   }   
}

function shoot()
{
   if(bShootEnable == true)
      return;
   bShootEnable = true;
   VECTOR temp;
   temp.x = mouse_pos.x;
   temp.y = mouse_pos.y;
   temp.z = 250;  // Länge des Strahls
   vec_for_screen(temp,camera);
   
   c_trace(nullvector,temp,ACTIVATE_SHOOT);
   
   var timeLeft = 5;
   do
   {
      wait(1);
      timeLeft -= time_step;   
   }while(timeLeft > 0);
   
   bShootEnable = false;
}



Das Hexer-Modell ("warlock.mdl") habe ich hier hochgeladen: warlock.mdl (workupload.com)

Vielen Dank im Voraus blush
-------
I've uploaded the warlock model ("warlock.mdl") here: warlock.mdl (workupload.com)

Thanks in advance blush


Last edited by Nicros; 04/01/16 09:51.