Hey, I need your help with something. I want the plasma thrower's secondary fire to be more like the Revolution version; a consistent pattern, as opposed to totally random. But I can't find the way to make the projectile launch at an angle.
Viewing post in Serious Sam: The Sequel (Public Beta) comments
If you wanna modify your existing function, pass a unique index or something into each FirePlasmaRayAlt() call and then adjust the angle based on the index.
Replace CalcWeaponPositionImprecise() with CalcWeaponPosition() and modify plPlasmaRay.pl_OrientationAngle after its call. Or use plPlasmaRay.Rotate_Airplane() to add rotation relative to the current view.
I don’t know what that is or how it behaves but if you want a hitscan laser that follows the player instead of directly targeting them, I can propose this:
(1) Define a target angle for your enemy’s hitscan as ANGLE3D (e.g. m_aTowardsTarget) and optionally set it to the enemy’s orientation angle on start.
(2) When the enemy begins attacking, calculate an angle towards the target (m_penEnemy in enemy’s case) with a small delay before the actual attack:
FLOAT3D vToTarget = (m_penEnemy->GetPlacement().pl_PositionVector - GetPlacement().pl_PositionVector).Normalize();
ANGLE3D aToTarget;
DirectionVectorToAngles(vToTarget, aToTarget);
m_aTowardsTarget = aToTarget;
(3) During a continuous hitscan in a loop, calculate an angle difference between the current target angle and the angle towards the target. Reuse the same code as in step 2 but instead of setting angle to m_aTowardsTarget, do this:
aToTarget -= m_aTowardsTarget;
aToTarget(1) = NormalizeAngle(aToTarget(1));
aToTarget(2) = NormalizeAngle(aToTarget(2));
m_aTowardsTarget += aToTarget / 2;
Here the difference is divided by 2 to make it follow the target twice as slow. Adjust as needed or even clamp the maximum speed of each angle like this:
aToTarget(1) = Clamp(NormalizeAngle(aToTarget(1)), -30.0f, +30.0f);
(4) Then use the resulting angle in the CCastRay as the source:
CPlacement3D plLaser(vLaserPosRelativeToEnemy, m_aTowardsTarget);
CCastRay crLaser(this, plLaser, 500);
Or if the laser needs to just go from one side to another in the general direction of the player, add an initial angle to that target angle so it starts to the side and just add a specific fixed amount to the angle each loop iteration instead of the difference relative to the target.
The Carcinus Lurker is an enemy from Next Encounter. It shoots a laser in a sweeping motion from left to right and you're supposed to jump over it or duck under it. I did bring back the enemy, but never got that sweeping motion down, so it just shoots towards the player, even though the animation still does the sweeping motion. I was just wondering if that's possible.
You can code virtually any gameplay mechanic you want but I don’t think I’m capable of explaining it in simple terms/steps to someone who doesn’t really code.
Even disregarding the programming language, it all depends on how a specific mechanic works and the abstract steps you come up with in order to implement it.
In your case, the abstract steps would be something like this:
(1) Figure out the start angle for shooting the laser to the side of the current target.
(2) Rotate this angle in some direction with each game tick until it reaches a certain limit.
(3) Each time the angle changes, the laser needs to be physically shot using a raycast in the calculated direction of the current angle.
(4) Render the laser beam from the source to the hit point of a raycast as long as the attack is active.