Results 1 to 9 of 9
  1. #1
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Posts
    62

    Default help regarding bump function

    hello guys, i posted a similar thread on beyond unreal forums but got no help whatsoever from there.Hope i get atleast some kind of input here.

    this is my first post on this website.I am currently working on a project.

    I have an Enemy class who chases my player when the player is within specified distance. When he gets within a certain distance his health decreases.However i want my player to get a bump effect when the enemy is attacking.So i used the bump function when they both collide.But i am not able to make it bump.Only the health gets deducted.

    Here is my Code function in my Enemy class which extends UTPawn

    simulated event Tick(float DeltaTime)
    {
    local UTPawn gv;

    super.Tick(DeltaTime);
    MyController.Tick(DeltaTime);

    foreach CollidingActors(class'UTPawn', gv, 200)
    foreach VisibleCollidingActors(class'UTPawn', gv, 100)
    {
    if(AttAcking && gv != none)
    {
    if(gv.Health > 0)
    {

    gv.Health -= 1;
    Bump(self,CollisionComponent,vect(0,0,0));
    }
    }
    }
    }


    Then i have Defined my Bump function as follows

    event Bump(Actor other,PrimitiveComponent OtherComp, vector HitNormal)
    {
    TakeDamage(6,none,Location,vect(0,0,0),class'UTDmg Type_LinkPlasma');
    }

    However this does not seem to work. Kindly help with your inputs guys
    Thank you

  2. #2

    Default

    the 'Bump' is not terminology describing a push/ force effect.
    - bump does not mean - push / hit / cause an effect on another pawn.- cause a posisiton change.
    - the bump is something that notifies the engine that 'something has touched something else'.
    - a bump effect is not a bump;

    - i am certainly not great with code; but it sounds like....
    **you want to physically move pawn {A}; when Pawn {B} reaches close proximity/ collides with the player???
    - like, i think that requires a new damage type. [possibly one that applies radial force]

    im sure rattleSN4k3 will clear this issue up for you.; but it does appear that your trying to do something with the wrong code.

    p.s 3 people this week have said "this is my first post"- your post count says different [lol- only messing]
    Last edited by TKBS; 04-18-2012 at 01:43 PM.

  3. #3
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Posts
    62

    Default

    Hmm ya you might be correct on this one.

    Ya, i am trying to create a collision between the player and enemy when the enemy gets into close proximity of the the player and starts attacking it.

    Okay this was the first class i tried creating , IT IS NOT THE CLASS I MENTIONED IN MY FIRST POST SO DONT CONFUSE YOURSELVES.


    class AITestEnemy extends Actor placeable;

    var float BumpDamage;
    var Pawn enemy;
    var float followDistance;
    var float AttackDistance;
    var float MovementSpeed;
    var Material SeekingMat,AttackingMat,FleeMat;
    var StaticMeshComponent MyMesh;
    var bool bAttacking;
    var AIEnemyBlockers Blockers;




    state seeking
    {
    function Tick(float DeltaTime)
    {
    local vector newLocation;
    if(bAttacking)
    return;
    if(enemy == none)
    GetEnemy();
    if(enemy != none)
    {
    newLocation = Location;
    newLocation += normal(enemy.Location - Location) * MovementSpeed * DeltaTime;
    NewLocation += normal((Enemy.Location - Location) cross vect(0, 0, 1)) * MovementSpeed * DeltaTime;
    SetLocation(newLocation);
    if(Vsize(newLocation - enemy.Location) < AttackDistance )
    GoToState('Attacking');

    }
    }
    }

    function BeginState(Name PreviousStateName)
    {
    MyMesh.SetMaterial(0,SeekingMat);
    }



    auto state FastSeeking extends Seeking
    {
    function BeginState(Name PreviousStateName)
    {
    MovementSpeed = default.MovementSpeed * 2.0;
    if(!bAttacking)
    MyMesh.SetMaterial(0, SeekingMat);
    }
    }

    state Attacking
    {
    function Tick(float DeltaTime)
    {
    bAttacking = true;
    if(enemy == none)
    GetEnemy();
    if(enemy != none)
    enemy.Bump(self,CollisionComponent,vect(0,0,0));
    if(Vsize(Location - enemy.Location) > AttackDistance )
    GoToState('Seeking');
    }
    function BeginState(Name PreviousStateName)
    {
    MyMesh.SetMaterial(0, AttackingMat);
    }

    function EndState(Name PreviousStateName)
    {
    SetTimer(1,false,'EndAttack');
    }

    }

    state Fleeing
    {
    local vector newLocation;
    function Tick(float DeltaTime)
    {
    if(enemy == none)
    GetEnemy();
    if(enemy != none)
    {
    newLocation = Location;
    newLocation -= normal(enemy.Location - Location) * MovementSpeed * DeltaTime;
    SetLocation(newLocation);
    }
    }

    }


    function GetEnemy()
    {
    local AITestPlayerController PC;
    foreach LocalPlayerControllers(class'AITestPlayerControlle r',PC)
    {
    if(PC.Pawn != none)
    enemy = PC.Pawn;
    }
    }

    function RunAway()
    {
    GoToState('Fleeing');
    SetTimer(2.0,false,'NoState');
    }

    function NoState()
    {
    GoToState('');
    }

    function EndAttack()
    { bAttacking = false;
    }







    defaultproperties
    {
    bBlockActors=True
    bWorldGeometry=True
    bCollideActors=True
    Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
    bEnabled=TRUE
    End Object
    Components.Add(MyLightEnvironment)
    Begin Object Class=StaticMeshComponent Name=PickupMesh
    StaticMesh=StaticMesh'UN_SimpleMeshes.TexPropCube_ Dup'
    Materials(0)=Material'EditorMaterials.WidgetMateri al_X'
    LightEnvironment=MyLightEnvironment
    Scale3D=(X=0.25,Y=0.25,Z=0.5)
    End Object
    Components.Add(PickupMesh)
    Begin Object Class=CylinderComponent Name=CollisionCylinder
    CollisionRadius=32.0
    CollisionHeight=64.0
    BlockNonZeroExtent=true
    BlockZeroExtent=true
    BlockActors=true
    CollideActors=true
    End Object
    CollisionComponent=CollisionCylinder
    Components.Add(CollisionCylinder)

    BumpDamage = 5.0;
    followDistance = 512.0;
    MovementSpeed = 175.0;
    AttackDistance = 25.0;

    SeekingMat=Material'EditorMaterials.WidgetMaterial _X'
    AttackingMat=Material'EditorMaterials.WidgetMateri al_Z'
    FleeMat=Material'EditorMaterials.WidgetMaterial_Y'

    Begin Object Class=StaticMeshComponent Name=EnemyMesh
    StaticMesh=StaticMesh'UN_SimpleMeshes.TexPropCube_ Dup'
    Materials(0)=Material'EditorMaterials.WidgetMateri al_X'
    LightEnvironment=MyLightEnvironment
    Scale3D=(X=0.25,Y=0.25,Z=0.5)
    End Object
    Components.Add(EnemyMesh)
    MyMesh=EnemyMesh

    }


    Okay for this class that i created that extends Actor, i can successfully create a collision between my enemy and player but in my current problem with my new enemy class which derives from UTPAWN class i am not able to create a collision bumpy effect between my enemy and player even with using the same set of functions.

  4. #4

    Default

    At first:
    Try to encapsulate code segments with [code] and [/code].

    Which look looks like this in a textbox.

    [code]
    class Whatever extends Object;

    function A()
    {
    }
    [/code]


    and will result into
    Code:
    class Whatever extends Object;
    
    function A()
    {
    }
    ------------------------

    Regarding a bump effect:

    What do you want as a bump effect. Just a visual effect or should the pawn/player be moved a bit?
    A visual effect should be applied as a camera shake effect. If you want to move a pawn/player a bit you can look at the TakeDamage function in the Pawn class. The momentum parameter applies a force to the pawn by adding a velocity.
    Code:
    [...]
    AddVelocity( momentum, HitLocation, DamageType, HitInfo );
    [...]

    ---------

    Regarding your code from first post:

    There are too much iteration in your tick function. And you don't need to call a tick function of another actor (like the Controller). Generally a Tick is triggered natively by the engine every produced image. If you want to apply a force once or in a interval use a Timer.

    Code:
    class TimedSomething extends Actor;
    
    function PostBeginPlay()
    {
    	super.PostBeginPlay();
    
    	// call TimedFunction every 500 ms in a loop
    	SetTimer(0.5, true, 'TimedFunction');
    }
    
    function TimedFunction()
    {
    	// Do something like adding velocity
    }

    AS TKBS already mentioned, the Bump function is triggered by the engine itself if two actors collides. If you want to apply damange to the Player when both Actors (the Player's pawn and the enemy) collides, you can use this Bump function by adding this TakeDamage function with proper parameters. But remember, bump is only called once on colliding each other. So if the player stands still, the enemy just bumps into the player once, and only damages/attacks him once.

  5. #5
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Posts
    62

    Default

    Okay so i used the TakeDamage Function for the push effect but i am not getting the desired result. I need the player to jump back a little when he collides with the enemies.

    This is my Bump Function

    Code:
    event Bump(Actor other,PrimitiveComponent OtherComp, vector HitNormal)
    {
    if( AITestNewEnemy(other) != none && !bInvulnerable)
    bInvulnerable = true;
    SetTimer(InvulnerableTime,false,'EndInvulnerable');
    TakeDamage(AITestNewEnemy(other).BumpDamage,none,Location,vect(0,0,1)*2.5f,class'UTDmgType_LinkBeam');
    }
    I am not good with physics and maths so if any one can help me out with a formula to calculate momentum that would result in a push effect backwards.

  6. #6

    Default

    * this is very hard stuff if you do not know what your doing;

    - RattleSN4K3 provided me with this; but i have not fully implemented it yet

    -this is from one of my functions - you can use your "bump"; but personally i used this within my "Touch" function
    Code:
     local float force;
     local vector velo;
    
     velo = Other.Velocity;
                velo.z = 0;
                force = Vsize(velo);
                // RS: Print force
                `Log("Force:"@force);
    - again im sh1t with code; but it is my understanding that as with any code;
    declare your stuff [in your case force]
    - then have the engine notify you of - 'what the f is going on '
    use the output comment// 'Log ("blah: "@blah);

    - calculating a correct value requires either mathematical and unreal knowledge &/OR trial and error.
    - i fall into the later
    - good luck

    p.s. if you download udk; and look at "radialforce" and radial force actors; you should be able to create a new "damagetype"- and call this dmgtype when you activate your Bump
    Last edited by TKBS; 04-21-2012 at 04:18 PM.

  7. #7

    Default

    UTDmgType_Redeemer

    ^^
    KDamageImpulse=20000
    KImpulseRadius=5000.0
    - that will do the trick

    maybe this thread should be called "help regarding dmgtypes"

    lol

  8. #8
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Posts
    62

    Default

    Man your force and velocity formulae did actually do the trick !! I will also try the redeemer damage type.

    Thanks a lot !!!!!

  9. #9
    MSgt. Shooter Person
    Join Date
    Aug 2011
    Posts
    62

    Default

    This is my final bump function , thank you TKBS for the formula

    Code:
    event Bump(Actor other,PrimitiveComponent OtherComp, vector HitNormal)
    {
     local float force;
     local vector velo;
     velo = other.velocity;
     velo.z=0;
     force=Vsize(velo);
    
    if( AITestNewEnemy(other) != none && !bInvulnerable)
    bInvulnerable = true;
    SetTimer(InvulnerableTime,false,'EndInvulnerable');
    TakeDamage(AITestNewEnemy(other).BumpDamage,none,Location,(velo*force)*0.5,class'UTDmgType_LinkBeam');
    }


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.