{"id":622,"date":"2025-04-28T12:42:04","date_gmt":"2025-04-28T12:42:04","guid":{"rendered":"https:\/\/sites.wsagames.com\/sc18g23\/?p=622"},"modified":"2025-05-14T18:47:52","modified_gmt":"2025-05-14T18:47:52","slug":"week-5-movement-acceleration-multiplier-bonus-gravity","status":"publish","type":"post","link":"https:\/\/sites.wsagames.com\/sc18g23\/2025\/04\/28\/week-5-movement-acceleration-multiplier-bonus-gravity\/","title":{"rendered":"Movement Acceleration Multiplier, Bonus Gravity,"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Movement Acceleration Multiplier<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">One of the suggestions I got from Guy was to make the player go faster, and so what I did was this, I made the player go progressively faster if they held down the move key, but reset it if they let go.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At the end of the MovePlayer function, I added this AddMovementMultiplier<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    void AddMovementMultiplier()\n    {\n        float newMultiplier = _movementMultiplier += movementMultiplierAmount;\n        if (newMultiplier &gt; maxMovementMultiplier)\n        {\n            return;\n        }\n        if (Mathf.Approximately(newMultiplier, maxMovementMultiplier))\n        {\n            _movementMultiplier = maxMovementMultiplier;\n        }\n        else\n        {\n            _movementMultiplier += movementMultiplierAmount;\n        }\n        Debug.Log($\"movementMultiplier: {_movementMultiplier}\");\n    }\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And then when the player stops moving, the _movementMultiplier is set to 0.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I also added a maxMovementMultiplier float to stop the player from going to fast and accelerating to ridiculous, uncontrollable speeds. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Bonus Gravity<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Another change I made was an addition of a ForceMultiplier variable. Firstly, I made some changes to the PlayerInput, adding Inputs to accommodate the arrow keys.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then, I added code in the SelectionArea script. I made a new float called abilityMultiplier and then some functions that interacted with the new Inputs I added.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public void ScrollUp(InputAction.CallbackContext context)\n    {\n        if (!context.performed) return;\n        abilityMultiplier += 1;\n        Debug.Log($\"Scrolling up ability multiplier: {abilityMultiplier}\");\n    }\n\n    public void ScrollDown(InputAction.CallbackContext context)\n    {\n        if (!context.performed) return;\n        if (abilityMultiplier &gt; 0)\n        {\n            abilityMultiplier -= 1;\n        }\n        else\n        {\n            abilityMultiplier = 1;\n        }\n        Debug.Log($\"Scrolling down ability multiplier: {abilityMultiplier}\");\n    }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, in PlayerAbility, when the MoveObjectUsingGravity IEnumerator is called, a Vector3 called forceToAdd is made. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        objectRb.useGravity = false;\n        Vector3 forceToAdd = Vector3.up * (radius * _forceAmount * abilityMultiplier);\n        Debug.Log($\"Force to add {forceToAdd}\");\n        objectRb.DOMove(objectRb.transform.position + forceToAdd * Time.fixedDeltaTime, forceMovementTime);\n        yield return new WaitForSecondsRealtime(forceMovementEnd);\n        objectRb.useGravity = true;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">One of the changes I also made for the gravity ability is that, instead of moving the objects rigidbody, I added a force to the object affected by the ability, and so the DOMove would be replaced with this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>objectRigidBody.AddForce(Vector3.up * radius * _forceAmount, ForceMode.Acceleration);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On Thursday, I provided this summary of what I did to the Discord server:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"922\" height=\"1024\" src=\"https:\/\/sites.wsagames.com\/sc18g23\/wp-content\/uploads\/sites\/9\/2025\/04\/Screenshot-2025-04-28-at-11.28.11-922x1024.png\" alt=\"\" class=\"wp-image-623\" srcset=\"https:\/\/sites.wsagames.com\/sc18g23\/wp-content\/uploads\/sites\/9\/2025\/04\/Screenshot-2025-04-28-at-11.28.11-922x1024.png 922w, https:\/\/sites.wsagames.com\/sc18g23\/wp-content\/uploads\/sites\/9\/2025\/04\/Screenshot-2025-04-28-at-11.28.11-270x300.png 270w, https:\/\/sites.wsagames.com\/sc18g23\/wp-content\/uploads\/sites\/9\/2025\/04\/Screenshot-2025-04-28-at-11.28.11-768x853.png 768w, https:\/\/sites.wsagames.com\/sc18g23\/wp-content\/uploads\/sites\/9\/2025\/04\/Screenshot-2025-04-28-at-11.28.11-300x333.png 300w, https:\/\/sites.wsagames.com\/sc18g23\/wp-content\/uploads\/sites\/9\/2025\/04\/Screenshot-2025-04-28-at-11.28.11-850x944.png 850w, https:\/\/sites.wsagames.com\/sc18g23\/wp-content\/uploads\/sites\/9\/2025\/04\/Screenshot-2025-04-28-at-11.28.11.png 1068w\" sizes=\"(max-width: 922px) 100vw, 922px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Movement Acceleration Multiplier One of the suggestions I got from Guy was to make the player go faster, and so what I did was this, I made the player go progressively faster if they held down the move key, but reset it if they let go. At the end of the MovePlayer function, I added&#8230;<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-622","post","type-post","status-publish","format-standard","hentry","category-semester-2-kinetic-panic"],"_links":{"self":[{"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/posts\/622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/comments?post=622"}],"version-history":[{"count":5,"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/posts\/622\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/media?parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/categories?post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wsagames.com\/sc18g23\/wp-json\/wp\/v2\/tags?post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}