(02-16-2025, 07:22 PM)Pixelwolf Wrote: Makes sense, collision of the projectile is determined by the size of the sprite so if it is to big it will touch the ground and destroy it
I just got this from asking chat gpt. Does it look legit or is it way out there?...
VP said:
In "efpse ce" game engine, I have a 3D model attached to a 2D enemy sprite. The helicopter fires a projectile at the player. The helicopters height is fixed at 240 but the projectile fires from the 2D sprite position, instead of the 3D model's position. How do I just adjust the projectile's height to 240?
ChatGPT said:
Got it! If the helicopter is already firing a projectile and you just need to adjust the projectile's height to a fixed value of 240, you can simply adjust the projectile's Z-position after it has been fired.
Assuming that the projectile has already been spawned and you're just looking to modify its height, you can use a script to update the projectile's Z-position directly.
Here's an example of how you can adjust the projectile's height to 240 after it has been fired:
Script to Adjust Projectile Height to 240
// Set the fixed height for the projectile
map.fixedHeight = 240
// Get the current position of the projectile
entity check position Projectile $map.projectilePosX $map.projectilePosY $map.projectilePosZ
// Adjust the Z-position (height) of the projectile to the fixed value (240)
entity move Projectile $map.projectilePosX $map.projectilePosY $map.fixedHeight
Explanation:
Set Fixed Height: The variable map.fixedHeight is set to 240, which is the height you want the projectile to always be at.
Get Current Position: The script retrieves the current X, Y, Z position of the projectile using entity check position.
Update Z-Position: The entity move command is used to update the Z-position (height) of the projectile, setting it to 240, while keeping the X and Y positions unchanged.
To add this script to your game in Easy FPSE Editor, follow these steps:
1. Create a Script File
Open a text editor (like Notepad or Notepad++), and paste the script into the editor.
Save the file with a .script extension. For example, you might name it HelicopterProjectileHeight.script or another name based on your needs.
The script file should be saved in the Data/Scripts directory of your project.
2. Script File Location
Make sure the script is saved in the correct location within your project directory. The directory should be ProjectFolder/Data/Scripts.
If the folder doesn't exist yet, you will need to create it.
3. Triggering the Script
You need to trigger the script either by a map event or through the helicopter's actions. You can do this by linking the script to the helicopter's shooting action or through a trigger event.
To link the script to an action (like shooting the projectile), use a trigger or attach it to the helicopter's behavior through the appropriate event in your game.
For example:
If the script should run when the helicopter fires a projectile, ensure the trigger is set in the helicopter's behavior to call this script.
4. Testing the Script
After saving the script and linking it to the appropriate entity (the helicopter's shooting behavior), test the game.
Play the game and check if the projectile's height is set correctly to 240.
5. Debugging (if necessary)
If the script doesn't work as expected, double-check the following:
Ensure that the name of the projectile entity is correct. If the entity is named something different, replace "Projectile" with the correct entity name.
Verify that the script is properly triggered during gameplay (i.e., when the helicopter fires the projectile).
Check the logs or debug console for any error messages that might provide more information on what went wrong.
6. Repeat the Process as Needed
If any adjustments or refinements are needed (like adding more logic to the script), update the script in the text editor and re-save it.
Reload the game or trigger the script again to see if the changes work.
By following these steps, the script should be integrated into your game, and the projectile should correctly adjust its height to 240.