The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Spawned projectiles won't move?

  • Filter
  • Time
  • Show
Clear All
new posts

  • 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:
     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.

  • #2
    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

    simulated function Projectile ProjectileFire()
    	local vector		RealStartLoc, AimDir;
    	local Projectile	SpawnedProjectile;
    	// tell remote clients that we fired, to trigger effects
    	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
      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.


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

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


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

          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.


          • #6
            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):


            • #7
              That did indeed do the trick.

              What exactly does that do? How does that method allow you to use a rotation to a vector?


              • #8
                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.