rts control problems

hi I have been making an rts camera control system for my game using Createathings YouTube tutorial code as a base and expanding but now certain inputs only work if I press them in combo with control here’s the code:

using UnityEngine;
using System.Collections;

public class cameramovement : MonoBehaviour
{
	
		public int edgeboundry = 10;
		public int minheight = 18;
		public int maxheight = 400;
		bool minheightreached = false;
		bool maxheightreached = false;
	
		void start ()
		{
		
		
		}
	
		// Update is called once per frame
		void Update ()
		{
		
				if (transform.position.y == minheight) {
						minheightreached = true;
				}
				if (transform.position.y == maxheight) {
						maxheightreached = true;
				}
		
		
				Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
				RaycastHit hit;
				if (Physics.Raycast (ray, out hit, 1000))
				
				if (Input.GetMouseButtonDown (0))
				if (hit.collider.tag == "world") {                  
				
						Debug.Log ("hello world");
				} else 
						return;
		
				
		
		
				if (Input.GetKey ("left ctrl") && (Input.mousePosition.y < Screen.height / edgeboundry || Input.GetButton ("Vertical") && Input.GetAxis ("Vertical") < 0)) {             //first part only works if control is pressed but i want the second to to work regardless
			
						transform.position += new Vector3 (0, 0, -0.2f);
			
				}
		
				if (Input.GetKey ("left ctrl") && (Input.mousePosition.y > Screen.height - Screen.height / edgeboundry || Input.GetButton ("Vertical") && Input.GetAxis ("Vertical") > 0)) {                //first part only works if control is pressed but i want the second to to work regardless
			
						transform.position += new Vector3 (0, 0, 0.2f);
			
				}
				if (Input.GetKey ("left ctrl") && (Input.mousePosition.x < Screen.width / edgeboundry || Input.GetButton ("Horizontal") && Input.GetAxis ("Horizontal") < 0)) {             //first part only works if control is pressed but i want the second to to work regardless
				
						transform.position += new Vector3 (-0.2f, 0, 0);
			
				}
				if (Input.GetKey ("left ctrl") && (Input.mousePosition.x > Screen.width - Screen.width / edgeboundry || Input.GetButton ("Horizontal") && Input.GetAxis ("Horizontal") > 0)) {         //first part only works if control is pressed but i want the second to to work regardless   
			
						transform.position += new Vector3 (0.2f, 0, 0);
				}
				
				if (Input.GetButton ("Ymovement") && !(minheightreached)) {    //custom input not working 
				
						transform.position += new Vector3 (0, -0.2f, 0);
				
				}
				
				if (Input.GetButton ("Ymovement") && !(maxheightreached)) {    //custom input not working 
					
						transform.position += new Vector3 (0, 0.2f, 0);
				
				}
				
		}
}

there is another problem I made a custom input as you can see(Ymovement) but pressing the buttons assigned (space ans shift) nothing happens,could someone help, what have I done wrong and what should i change to fix this

So in this case you just have a Boolean logic issue in your if’s.

You have brackets around all of the Boolean logic after the first && so it only works with crtl pressed.

// your compacted if
ctrl && (mouseX  || Button Horizontal && Axis Horizontal > 0)
// so I guess you want
(crtl && mouseX) || (Button Horizontal && Axis Horizontal > 0)
// also since the first Input check will always be true if it is > 0 or < 0 
// you don't need the first Input check, so you should only need
(crtl && mouseX) || Axis Horizontal > 0

If you are trying to do something else, that would need different logic.

The other bug which is that the “Ymovement” input will be true regardless of whether the positive or negative button key is being pressed. So both IF statements are evaluating to true which results in no movement. So switch one to Input.GetAxis ("Ymovement") > 0 and the other to Input.GetAxis ("Ymovement") < 0.

Hope that helps!

Edit: fixed GetButton/GetAxis mixup

Did you know you can use Event Trigger > On Pointer Enter and On Pointer Exit to control edge detection for a RTS camera?
I’ve done that for a Tower defense project I’m working on.