Results 1 to 7 of 7
  1. #1

    Default Pickup Item moving/bobbing up n down

    I have written previously a custom platform, that you could add to your level with what ever mesh, set its parameters, and it would start moving up n down (or left n right).
    ive now created a simple item collection extending from UTItemPickupFactory - which extends all the way from Navigation Point

    i would like to take my movement code and add it to the item so it bounces up n down
    obviously Nav Point isnt moveable

    could anyone suggest a good way round this?

    i suppose i could just use the code from the Platform (which extends Actor) and add all the Item Collection functionality...
    ANy better ideas ?

  2. #2
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Shanghai
    Posts
    309

    Default

    Did some digging and came up with one way to do it. There may be other (and maybe better) ways to do it but here it is.

    Every PickupFactory has a PickupMesh which is the mesh of the item the PickupFactory holds. This mesh is being shown in-game when the item is ready for you to pick up, and at this point the PickupFactory is in the state Pickup. What you want to do in this state is to add any movement code you have and apply it to PickupMesh. The problem is that the PickupMesh is of type PrimitiveComponent which means it has no location property, and therefore you can't change the location of it. However, you can spawn an actor and attach PickupMesh to it. When you've done that, you can apply the movement code to the actor and the mesh will move with it.

    Code:
    class MeshHolder extends Actor;
    
    simulated function Tick (float DeltaTime)
    {
    	local vector NewLocation;
    	
    	NewLocation = Location;
    	NewLocation.Z += Velocity.Z;
    }
    Code:
    class MyPickupFactory extends PickupFactory;
    
    var MeshHolder MyMeshHolder;
    
    simulated function SetPickupMesh()
    {
    	if ( InventoryType.Default.PickupFactoryMesh != None )
    	{
    		if (PickupMesh != None)
    		{
    			if (MyMeshHolder != None)
    			{
    				MyMeshHolder.DetachComponent(PickupMesh);
    				MyMeshHolder.Destroy();
    			}
    			PickupMesh = None;
    		}
    
    		PickupMesh = new(self) InventoryType.default.PickupFactoryMesh.Class(InventoryType.default.PickupFactoryMesh);
    
    		if (MyMeshHolder == None)
    			MyMeshHolder = Spawn(class'MeshHolder',self,,Location,,,);
    
    		MyMeshHolder.AttachComponent(PickupMesh);
    
    		if (bPickupHidden)
    		{
    			SetPickupHidden();
    		}
    		else
    		{
    			SetPickupVisible();
    		}
    	}
    }
    
    auto state Pickup
    {
    	function ChangeDirection()
    	{
    		if (MyMeshHolder != None)
    			MyMeshHolder.Velocity.Z *= -1;
    	}
    
    	event BeginState(name PreviousStateName)
    	{
    		MyMeshHolder.SetLocation(Location);
    		MyMeshHolder.Velocity.Z = 5.0;
    
    		SetTimer(1.0,true,'ChangeDirection');
    
    		super.BeginState(PreviousStateName);
    	}
    
    	event EndState(name NextStateName)
    	{
    		ClearTimer('ChangeDirection');
    		super.EndState(NextStateName);
    	}
    }

  3. #3
    Boomshot
    Join Date
    Aug 2011
    Posts
    2,280

    Default

    If you just want the mesh to bob up and down in-place, a common effect in many shooters like Quake3, you can modulate the primitive component's translation.

    Code:
    var float BobRate, BobDistance;
    
    event Tick( float dt )
    {
        local Vector v;
        v.z = Sin(WorldInfo.TimeSeconds * BobRate) * BobDistance;
        Mesh.SetTranslation(v);
    }
    
    DefaultProperties
    {
        BobRate = 10.0
        BobDistance = 64.0
    }

  4. #4

    Default

    @evr, yea that was something i began doign last night but got too tired. will have another go tonight
    @spoof, i didnt realise I could do it by translation. i thought i would need an actor that has access to Location and to Move() functionality.Is that really how they did it in Q3 ? I will give this a go tonight as well.

    Thanks guys, will report back

  5. #5
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Shanghai
    Posts
    309

    Default

    Yeah I'd go with Spoof's method, that was way better.

  6. #6

    Default

    ok will do.
    quick question, with spoofs way, the mesh will move up and down, but the actual "touch" event - for the item collection will not move will it ?

  7. #7
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Location
    Shanghai
    Posts
    309

    Default

    No, just the mesh. You have a CollisionCylinder for stuff like "touch". (See defprops for placeable pickupfactories)


 

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.