Crystal Space
Welcome, Guest. Please login or register.
November 24, 2014, 07:43:24 am

Login with username, password and session length
Search:     Advanced search
9018 Posts in 2046 Topics by 9099 Members
Latest Member: Basiahosa
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Game Content Creation
| | |-+  need some help with aggro
« previous next »
Pages: [1] 2 Print
Author Topic: need some help with aggro  (Read 11026 times)
Panch
Jr. Member
**
Posts: 80


View Profile Email
« on: July 25, 2007, 07:09:30 pm »

Hello again,

I had 2 ideas. The first didn't look like it could be implemented with CS although I could be wrong. I wanted to have a sphere collider extend to some point around any given mesh. When my 'hero' mesh isect'd with that sphere collider we would have aggro. But in CS the sphere collider will actually cause complete collision.

The other way is using a dynamic hit beam result like this:

Code:
EnemyStart = enemy->GetMovable()->GetPosition();
  EnemyEnd = hero->GetMovable()->GetTransform().GetOrigin();
  EnemySector = enemy->GetMovable()->GetSectors()->Get (0);
  // Do a beam to check if we hit something
  csSectorHitBeamResult rc = EnemySector->HitBeamPortals (
  EnemyStart, EnemyEnd-EnemyStart);

Which sorta works, but only works when I get right in front of the enemy. I'd like for it be say 15 or 20 units away from the enemy mesh. How could I do this?

Thanks!
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: July 25, 2007, 07:18:55 pm »

Hello again,

I had 2 ideas. The first didn't look like it could be implemented with CS although I could be wrong. I wanted to have a sphere collider extend to some point around any given mesh. When my 'hero' mesh isect'd with that sphere collider we would have aggro. But in CS the sphere collider will actually cause complete collision.

What is 'aggro'? But in any case, an object which is fully enclosed in the sphere will not hit the sphere. Only when the object crosses the sphere surface is there a hit.

Quote
The other way is using a dynamic hit beam result like this:

Code:
EnemyStart = enemy->GetMovable()->GetPosition();
  EnemyEnd = hero->GetMovable()->GetTransform().GetOrigin();
  EnemySector = enemy->GetMovable()->GetSectors()->Get (0);
  // Do a beam to check if we hit something
  csSectorHitBeamResult rc = EnemySector->HitBeamPortals (
  EnemyStart, EnemyEnd-EnemyStart);

Which sorta works, but only works when I get right in front of the enemy. I'd like for it be say 15 or 20 units away from the enemy mesh. How could I do this?

Thanks!

Just calculate an end point beyond EnemyEnd by taking the EnemyEnd-EnemyStart vector and multiplying that with some factor.

Greetings,
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #2 on: July 25, 2007, 07:34:30 pm »

Hey Jorrit Smiley

By 'aggro' I mean a certain distance or criteria where the enemy notices me and therefor begins attacking.

Quote
taking the EnemyEnd-EnemyStart vector and multiplying that with some factor

sound promising, I'll try that as soon as I can!

Quote
Only when the object crosses the sphere surface is there a hit.
This is actually the way I though about it originally but say: I spawn an enemy mesh which has working collision detection. Then I want to place this sphere around it to test collision against my hero player but not the world. There isn't a way to do that right? The sphere is effectively the whole collider, world and all?
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: July 25, 2007, 08:06:38 pm »

Quote
Only when the object crosses the sphere surface is there a hit.
This is actually the way I though about it originally but say: I spawn an enemy mesh which has working collision detection. Then I want to place this sphere around it to test collision against my hero player but not the world. There isn't a way to do that right? The sphere is effectively the whole collider, world and all?

You can create a new collider for that sphere but not make a csColliderWrapper. i.e. keep the collider private to your own code. Then the basic collision detection system will not know about the sphere and you can use that collider to test individual collisions with the hero player alone (ignoring the world). This is not that hard to do. It involves directly using the iCollideSystem interface.

Greetings,
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #4 on: July 25, 2007, 11:14:51 pm »

Ok, thanks Smiley That's more along the lines I wanted to do in the first place. This way keeps the frame per frame calculations down as well.

Thanks again!
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #5 on: July 25, 2007, 11:47:49 pm »

last dumb question for awhile. But i can't seem to pick up the const csReversibleTransform*. If i do:

Code:
const csReversibleTransform* trans2 = hero->GetMovable()->GetFullTransform();


It says cannot initialize

If I do:

Code:
const csReversibleTransform trans2 = hero->GetMovable()->GetFullTransform();

It says cannot convert.


I've been staring at old VB6 all day and my minds gone...
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #6 on: July 26, 2007, 05:16:19 am »


Code:
const csReversibleTransform trans2 = hero->GetMovable()->GetFullTransform();

It says cannot convert.


I've been staring at old VB6 all day and my minds gone...


Remove the 'const'.

Greetings,
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #7 on: July 26, 2007, 06:36:59 pm »

...sigh... I don't know why I can't see this one. If I set it as you've said and try to pass it, I get:

Code:
Error 4 error C2664: 'iCollideSystem::Collide' : cannot convert parameter 2 from 'csReversibleTransform' to 'const csReversibleTransform *' e:\cs stuff\time\input.cpp 45

I tried just streamlining mesh->GetMovable()->GetFullTransform() but it said the same.
thanks,
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #8 on: July 26, 2007, 06:41:27 pm »

And you removed the 'const'? Show me the code.

Greetings,
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #9 on: July 26, 2007, 08:08:57 pm »

Sure thing:

Code:
iPolygonMesh* polmesh1 =
enemy->GetMeshObject()->GetObjectModel()->GetPolygonMeshColldet();
   iPolygonMesh* polmesh2 =
hero->GetMeshObject()->GetObjectModel()->GetPolygonMeshColldet();

   csReversibleTransform trans1 = enemy->GetMovable()->GetFullTransform();
   csReversibleTransform trans2 = hero->GetMovable()->GetFullTransform();

if (polmesh1)
{
csRef<iCollider> cd1 = cdsys->CreateCollider (polmesh1);
csRef<iCollider> cd2 = cdsys->CreateCollider (polmesh2);

if (cdsys->Collide(cd1, trans1, cd2, trans1))
csPrintf("hit!");
//return cd;
}
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #10 on: July 26, 2007, 08:45:22 pm »

Hmm that looks ok. Can you give me the complete output of the compiler too?

Greetings,
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #11 on: July 26, 2007, 10:44:31 pm »

Sure thing:

Code:
------ Build started: Project: Time_Release, Configuration: Release Win32 ------
Compiling...
weapons.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
time.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
..\Time\time.cpp(188) : warning C4018: '<' : signed/unsigned mismatch
sounds.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
pathing.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
particles.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
..\Time\particles.cpp(197) : warning C4305: 'argument' : truncation from 'double' to 'float'
meshes.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
mapZero.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
mapTwo.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
mapOne.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
levelInit.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
input.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
..\Time\input.cpp(46) : error C2664: 'iCollideSystem::Collide' : cannot convert parameter 2 from 'csReversibleTransform' to 'const csReversibleTransform *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
gui.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
console.cpp
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(14) : warning C4005: '_CRT_SECURE_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(103) : see previous definition of '_CRT_SECURE_NO_DEPRECATE'
C:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(16) : warning C4005: '_CRT_NONSTDC_NO_DEPRECATE' : macro redefinition
        E:\CS Stuff\CS\include\csutil/win32/csconfig.h(110) : see previous definition of '_CRT_NONSTDC_NO_DEPRECATE'
Build log was saved at "file://e:\CS Stuff\Time_Release\Release\BuildLog.htm"
Time_Release - 1 error(s), 28 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thanks Smiley
« Last Edit: July 26, 2007, 11:52:08 pm by Panch » Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #12 on: July 27, 2007, 05:15:39 am »

Hmm, no clue what is wrong. The code is correct. Make sure that you are compiling the right code and that it is not some other file that is giving the error.

Greetings,
Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #13 on: July 27, 2007, 06:15:52 pm »

Oh man Sad, yeah I double checked both. I also checked it against both the debug library and the release library. I'll try another collilder method to see if I get the same error. Maybe this is a bug?

EDIT -
Well it definitely looks like something is wrong. When I modify collider.h to:

Code:
  virtual bool Collide (
  iCollider* collider1, csReversibleTransform trans1,
  iCollider* collider2, csReversibleTransform trans2) = 0;

It compiles fine, but throws errors in the opcode files when the app tries to run. I've searched through the test app's and didn't find any use of iCollideSystem::Collide() in anything. I've also tried all sorts of casts and what not too.

Any other ideas?
« Last Edit: July 28, 2007, 02:47:50 am by Panch » Logged
Panch
Jr. Member
**
Posts: 80


View Profile Email
« Reply #14 on: July 28, 2007, 04:23:05 am »

And the answer! ampersands!

if (cdsys->Collide(cd1, &trans1, cd2, &trans2))

compiles just fine.

Thanks for helping me through it Jorrit Smiley
Logged
Pages: [1] 2 Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 8.699 seconds with 16 queries.