feat: add particles on player if it is not jumping (#25)

This commit is contained in:
djelalb 2024-12-16 11:59:21 +01:00 committed by GitHub
parent 27a16dcef7
commit a7c19a6549
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 4873 additions and 6 deletions

View File

@ -147,7 +147,8 @@ TextureImporter:
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
nameFileIdTable:
BaseScene_0: -2257217325195158302
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:

View File

@ -172,7 +172,9 @@ TextureImporter:
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
nameFileIdTable:
BaseSpike_0: -7710779685713120251
BaseSpike_1: 978792226429369126
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:

View File

@ -147,7 +147,8 @@ TextureImporter:
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
nameFileIdTable:
BaseSquare_0: -5986989983176976689
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:

File diff suppressed because it is too large Load Diff

View File

@ -7,26 +7,54 @@ public class PlayerScript : MonoBehaviour
public Vector3 initialPosition;
public ParticleSystem particleSystem;
public void Start()
{
initialPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z);
var mainModule = particleSystem.main;
mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
particleSystem.transform.parent = null;
}
public void Update()
{
transform.position += Time.deltaTime * 8.6f * Vector3.right;
if (Input.GetKeyDown(KeyCode.Space))
if (!IsJumping())
{
if (!IsJumping())
Vector3 Rotation = transform.rotation.eulerAngles;
Rotation.z = Mathf.Round(Rotation.z / 90) * 90;
transform.rotation = Quaternion.Euler(Rotation);
if (Input.GetKeyDown(KeyCode.Space))
{
rigidBody.AddForce(Vector2.up * 26.6581f, ForceMode2D.Impulse);
}
particleSystem.gameObject.SetActive(true);
}
else
{
particleSystem.gameObject.SetActive(false);
transform.Rotate(Vector3.back * 360 * Time.deltaTime);
}
particleSystem.transform.position = transform.position + new Vector3(-0.19f, -0.64f, 0);
particleSystem.transform.rotation = Quaternion.Euler(0, 0, 150.464f);
ParticleSystemSpeed();
}
private bool IsJumping()
{
return Mathf.Abs(initialPosition.y - transform.position.y) > 0.05f;
}
private void ParticleSystemSpeed()
{
var velocityOverLifetime = particleSystem.velocityOverLifetime;
velocityOverLifetime.x = rigidBody.linearVelocity.x;
}
}