mirror of
				https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
				synced 2025-06-27 11:58:51 +02:00 
			
		
		
		
	feat: add particles on player if it is not jumping (#25)
This commit is contained in:
		| @@ -147,7 +147,8 @@ TextureImporter: | ||||
|     secondaryTextures: [] | ||||
|     spriteCustomMetadata: | ||||
|       entries: [] | ||||
|     nameFileIdTable: {} | ||||
|     nameFileIdTable: | ||||
|       BaseScene_0: -2257217325195158302 | ||||
|   mipmapLimitGroupName:  | ||||
|   pSDRemoveMatte: 0 | ||||
|   userData:  | ||||
|   | ||||
| @@ -172,7 +172,9 @@ TextureImporter: | ||||
|     secondaryTextures: [] | ||||
|     spriteCustomMetadata: | ||||
|       entries: [] | ||||
|     nameFileIdTable: {} | ||||
|     nameFileIdTable: | ||||
|       BaseSpike_0: -7710779685713120251 | ||||
|       BaseSpike_1: 978792226429369126 | ||||
|   mipmapLimitGroupName:  | ||||
|   pSDRemoveMatte: 0 | ||||
|   userData:  | ||||
|   | ||||
| @@ -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
											
										
									
								
							| @@ -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; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user