// Use this for initialization void Start() { myBody = GetComponent <Rigidbody2D>(); //lowerSpeed = 0; originalSpeed = -Random.Range(minSpeed, maxSpeed); gameObject.layer = 19; //make every AI to belong to layer AI backGroundScript = FindObjectOfType <ScrollingBackGround>(); backgroundSpeed = backGroundScript.getSpeed(); // ALWAYS REVERSE NOW. // original speed will carry dir now // -20 originalSpeed += backgroundSpeed; // bgSpeed is negative, keep in mind //-23 //lowerSpeed += DIR_DIFF; speedUsedTest = originalSpeed; desiredSpeed = originalSpeed; //float force = desiredSpeed * GetComponent<Rigidbody2D>().mass; myBody.velocity = new Vector2(desiredSpeed, 0); //GetComponent<Rigidbody2D>().AddForce(transform.right * force, ForceMode2D.Impulse); // Debug.Log("-----------------------------------speed set"); //speedUsed = originalSpeed; }
public override void Enter() { menu.AddMenuItem("Start"); menu.AddMenuItem("Options"); menu.AddMenuItem("Exit"); backGroundImage = Manager.Game.Content.Load <Texture2D>("Images/stars0"); scrollEffect = Manager.Game.Content.Load <Effect>("effects/TextureScroll"); backGround0 = Manager.VisualManager.CreateVisualObjectArg (VisualTypes.BackGroundScrollVisualType, backGroundImage, scrollEffect, Color.LightBlue ) as ScrollingBackGround; backGround0.UpdateCallBack = new ScrollingBackGround.OnUpdate(this.UpdateBackGround0); backGround1 = Manager.VisualManager.CreateVisualObjectArg (VisualTypes.BackGroundScrollVisualType, backGroundImage, scrollEffect, Color.White ) as ScrollingBackGround; backGround1.UpdateCallBack = new ScrollingBackGround.OnUpdate(this.UpdateBackGround1); menuVisual = Manager.VisualManager.CreateVisualObjectArg(VisualTypes.MenuVisualType, menu) as MenuVisual; }
// Start is called before the first frame update void Start() { backGroundScript = FindObjectOfType <ScrollingBackGround>(); backgroundSpeed = backGroundScript.getSpeed(); speedVector = new Vector2(backgroundSpeed + speed, 0); myBody = GetComponent <Rigidbody2D>(); }