How can i allow my character to jump if he has a powerup.,Changing a variable from one script to another
Hi. I have a game where a cube has a constant forward force pushing him along a ground plane and he has to avoid incoming obstacles. Very simple I know but this is only my third day knowing what Unity is and this is my first programming experience xD I have created a script which allows the cube to jump when clicking space bar. I now want to introduce a feature where in order for the cube to jump, he first has to pick up a powerup from the level. And then once the powerup is collected he then has the ability to jump, but only once. My original thought would be have a boolean such as canJump set to false. Upon collision between player and powerup game object, the game objects mesh render is turned off so its dissapears and the boolean canJump is now set to true. Then put my jump function in some sort of if statement saying that if canJump is true, the user can jump. And then as soon as the user jump's once, this turns the canJump back to false. Would this work and am I on the right tracks? Any help is much appreciated!,Hi im really new to unity and c# but im trying my best to teach myself it. I currently have a game where a cube has a constant forward force pushing it along a really long ground plane and the aim of the game is to avoid the incoming obstacles.. I now want to implement a feature where if the player collides with a coin or powerup etc it allows the user to jump, but only once. I have already coded the jump feature but now im trying to figure out how I would go about including this powerup feature. My original thought would be have a boolean such as canJump set to false. Upon collision between player and powerup game object, the game objects mesh render is turned off so its dissapears and the boolean canJump is now set to true. Then put my jump function in some sort of if statement saying that if canJump is true, the user can jump. And then as soon as the user jump's once, this turns the canJump back to false.
Sorry if this doesnt make any sense at all but with my 3 days of learning my first programming language this is all i can think of. Will this work? Any help would be great.
Your answer
Follow this Question
Related Questions
Error CS1519 1 Answer
How to get parent with component on collision? 0 Answers
Soccer game, more realistic net 1 Answer
How To Make A Character Stop At A Block? 0 Answers
Scripting trouble, Float on Collision/collision open gate 2 Answers