![]() Movement.direction = transform.TransformDirection (Vector3. This is used to keep track of special effects in UpdateEffects () Private var lastPlatformVelocity : Vector3 ![]() Private var activeGlobalPlatformPoint : Vector3 Private var activeLocalPlatformPoint : Vector3 Private var controller : CharacterController the height we jumped from (Used to determine for how long to apply extra jump power after lastStartHeight = 0.0 Last time we performed a lastTime = -1.0 Last time the jump button was clicked lastButtonTime = -10.0 Are we jumping? (Initiated with jump button and not grounded jumping = reachedApex = false Very handy for repeatTime = timeout = 0.15 The next line,, tells Unity to not serialize the variable or show it in the inspector view. This prevents inordinarily too quick jumping We add extraHeight units (meters) on top when holding the button down longer while jumping How high do we jump when pressing jump and letting go immediately We will contain all the jumping related variables in one helper class for clarity. Var movement : PlatformerControllerMovement This will keep track of how long we have we been in the air (not hangTime = 0.0 This keeps track of our current velocity while we're not inAirVelocity = Vector3.zero We will keep track of an approximation of the character's current velocity, so that we return it from GetVelocity () for our camera to use for velocity : Vector3 The last collision flags returned from collisionFlags : CollisionFlags I wrote a previous article in my hobbyist coder series about a way to code a custom 2D platformer controller in Unity 3D, especially to avoid this kind of problems. Is the user pressing the left or right movement isMoving = false The same way, if the player wants to jump when the character reaches the end of a platform, he may reacts just a few frames too late while the character just start to fall. The current vertical verticalSpeed = 0.0 This controls how fast the graphics of the character "turn around" when the player turns around using the controls. How fast does the character change speeds? Higher is faster. when pressing "Fire1" button (control) we start running This could be changed via a script at runtime to implement, e.g. The character will spawn at spawnPoint's position when needed. Does this script currently respond to Input? I’ve been trying to figure out how to change the community 2d platformer controller script to make it so that when the player jumps while standing still, they are allowed to move left and right still.Ĭurrently with the given script, if the player was to jump standing still, they would be stuck along the y-axis, and can change rotation, but not position along the x-axis.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |