Results 1 to 8 of 8
  1. #1

    Default Spawned projectiles won't move?

    The projectile's coding is fine (I've even tested spawning an existing UTProjectile), but for some reason, it won't move. I believe it has to do with how I spawn it.

    Here's my spawn script:
    Code:
     SpawnProjectile = Spawn(class'SMProjectile', , , LWTranslation, LWRotation, , true);
    LW is a socket, and SpawnProjectile is an Actor variable.

    I noticed that projectile's use direction, could the lack of one be why? Or is direction just the projectile's term for rotation?

    Edit: Wait, direction is a Vector? How is that possible? How can you determine the direction of something just by seeing where it is?
    I am trying to understand how direction works, so that I can set my own direction.
    Last edited by Graylord; 08-25-2011 at 11:29 PM.
    I'm making a game!

    http://www.desura.com/games/modulated
    Click the link above to read more!

  2. #2

    Default

    In my code, I just use the Projectile's Init() function, which takes in a vector for direction. (The Init() function sets the direction and speed).

    e.g., this is a function in my customized weapon class

    Code:
    simulated function Projectile ProjectileFire()
    {
    	local vector		RealStartLoc, AimDir;
    	local Projectile	SpawnedProjectile;
    
    	// tell remote clients that we fired, to trigger effects
    	IncrementFlashCount();
    
    	if( Role == ROLE_Authority )
    	{
    		// this is the location where the projectile is spawned.
    		RealStartLoc = GetPhysicalFireStartLoc();
    
    		// determine the aim direction
    		AimDir = Vector(GetAdjustedAim( RealStartLoc ));
    		AimDir.Z = 0;
    
    		// Spawn projectile
    		SpawnedProjectile = Spawn(GetProjectileClass(), Self,, RealStartLoc,,,true);
    		if( SpawnedProjectile != None && !SpawnedProjectile.bDeleteMe )
    		{
    			SpawnedProjectile.Init( AimDir );
    		}
    
    		// Return it up the line
    		return SpawnedProjectile;
    	}
    
    	return None;
    }

  3. #3

    Default

    I'm not using the weapon system as it doesn't fit my gameplay and just adds a lot of complexities I don't need, so I am skipping it and spawning it straight from the controller.

    So AimDir/Direction is just the location minus the Z axis?

    When I tried that, the projectile spawns somewhere out of sight. =\

    All I need really is a way to send it in the direction I want.
    Last edited by Graylord; 08-26-2011 at 12:58 AM.
    I'm making a game!

    http://www.desura.com/games/modulated
    Click the link above to read more!

  4. #4

    Default

    No, that's just something I'm doing tailored to my own game.

    What you want to look at is this:
    Code:
    SpawnedProjectile.Init( AimDir );
    And this is what that Init() function does:
    Code:
    /* Init()
    initialize velocity and rotation of projectile
    */
    function Init( Vector Direction )
    {
    	SetRotation(Rotator(Direction));
    	Velocity = Speed * Direction;
    }
    In other words, you just need to set the rotation of the spawned projectile.

  5. #5

    Default

    I have already seen what the init does, and it didn't really help me.

    Code:
    SetRotation(Rotator(Direction));
    Gives me a "missing ( or )" if I use my own rotator.

    I still don't see what the direction is, all I have is the Location and the rotation of the spawnpoint.
    It won't let me use rotation, and if I set the vector to the same as it's spawnpoint, the projectile is nowhere to be seen.
    Last edited by Graylord; 08-26-2011 at 02:18 AM.
    I'm making a game!

    http://www.desura.com/games/modulated
    Click the link above to read more!

  6. #6

    Default

    Assuming your current problem is a compile-time error, and looking back at your original thread post, how about just doing this (after you've spawned it):
    Code:
    SpawnProjectile.Init(Vector(LWRotation));

  7. #7

    Default

    That did indeed do the trick.

    What exactly does that do? How does that method allow you to use a rotation to a vector?
    I'm making a game!

    http://www.desura.com/games/modulated
    Click the link above to read more!

  8. #8

    Default

    It's not really a method. It's type-casting. Sort of like float(5) will convert the integer, 5, to a floating point value.

    Assume "mRotator" is a variable of type Rotator, and "mVector" is a vector of type Vector.

    Then Rotator(mVector) will appropriately convert mVector to a Rotator type, and similarly, Vector(mRotator) will appropriately convert mRotator to a Vector type.


 

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.