PDA

View Full Version : Collision detection in unreal script and Using c++ in runtime...(with picture)


flake1214
6th Apr 2006, 07:59 PM
Hi all,
I am new in coding unreal script for unreal runtime.

I edited a simple catching ball game

http://imlab.cs.nccu.edu.tw/~flake/sample.bmp

the arm and the ball are subclass of "StaticMeshActor" and they are
created in unreal script. I plan to let the arm to catch the ball. I
wonder how I can know the ball hit the arm. Is there any var in
"StaticMeshActor" can tell us this information, like the ball collides with
the arm?

The second question is that I'd like to know how we can let unreal
script communicate with c++, such as calling user-defined c++ function
in unreal script. I have found a website talks a little bit about it by using
.dll or some magical functions in unreal script

http://unreal.epicgame.com/CppObjects.html

However, I am still confused about how to exactly use them. Is there any
one can give me some help?

Thanks

Rebecca

Continuum
6th Apr 2006, 08:36 PM
To use any external code I believe you need the runtime, the link has a demo but I have no idea if the demo will work. I imagine you probably need to buy the runtime :(

http://udn.epicgames.com/Two/UnrealEngine2Runtime22262002

there are others that could probably answere your question better though (I think it is possible to run something through tcp... but I doubt it would be ideal for your situation)

flake1214
6th Apr 2006, 09:45 PM
Thanks for your quick reply, Continnum....

I have UT 2004 installed in my pc now. And I found there is wiki
website providing source code for UT2004 unreal script

http://wiki.beyondunreal.com/wiki/UnrealScript_Source

In some of the directories in the source code, such as Engine, we can
find there are .cpp files in it. I just wonder can we get these script compiled
in unreal runtime or only in UT2004 with .cpp files?


best,
Rebecca

Angel_Mapper
7th Apr 2006, 01:34 AM
The only way you can have the game communicate with C++ without a full engine license would be to use a UDP/TCP link:

http://wiki.beyondunreal.com/wiki/TcpLink
http://wiki.beyondunreal.com/wiki/UdpLink

As for collision, HitWall is called when an actor collides with a static mesh, as long as the one you're using isn't part of the HUD or the staticmesh of a Weapon subclass (those "aren't really there" as far as the world goes).

What you might want to do is make the arm an animated mesh (animations wouldn't be necessary, just the bones). You could then calculate wether or not the ball is in between two of the bones, say one in the pinky and thumb, to see if the ball has been caught, similar to how the Scorpion in UT2004 figures out if someone's been caught in the blades (this is in Tick):

....
local Coords ArmBaseCoords, ArmTipCoords;
local vector HitLocation, HitNormal;
local actor Victim;

ArmBaseCoords = GetBoneCoords('CarLShoulder');
ArmTipCoords = GetBoneCoords('LeftBladeDummy');
Victim = Trace(HitLocation, HitNormal, ArmTipCoords.Origin, ArmBaseCoords.Origin);

if (Victim != None && Victim.bBlockActors)
{
if (Victim.IsA('Pawn') && !Victim.IsA('Vehicle'))
Pawn(Victim).TakeDamage(1000, self, HitLocation, Velocity * 100, class'DamTypeONSRVBlade');

....