Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
4 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by blueangelicsoul · Feb 24 at 05:03 AM · addforce

Why does the spindash not launch off to a far distance?

I am making a Sonic-like 2D game and I am trying to get the spindash to work. It seems to charge correctly, but it is as if the way the force is applied doesn't allow the dash to launch off far. When running the game, I will charge the spindash and when I release it for it to shoot off, it barely moves. There is also an issue of it teleporting when its released and it dashes. For some reason, this problem only occurs in the X-direction. I am just testing it with a simple square because I have not added developed any original sprites yet. If anyone could help that would be great.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using TMPro;
 
 public class ModPlayerController : MonoBehaviour
 {
     public int speed = 10;
     public int jumpForce = 500;
     Rigidbody2D rigidBody;
     Animator animator;
 
     public TextMeshProUGUI actionText;
 
     //int bulletForce = 100;
     public LayerMask groundLayer;
     public Transform feetTrans; //empty gameObject
     bool grounded = false;
     float groundCheckDist = 0.3f;
     //public GameObject bulletPrefab;
     
     [SerializeField]private float stickForce;
     [SerializeField]private float spinDashSpeed;
     [SerializeField] private float minSpinDashTime;
     [SerializeField]private float springLaunchVelocity;
 
     private bool flipped;
     private bool underWater;
     private bool spinDashing;
     private float spinDashTimer;
     
 
 
     void Start()
     {
         rigidBody = GetComponent<Rigidbody2D>();
         animator = GetComponent<Animator>();
     }
 
     private void FixedUpdate()
     {
         grounded = Physics2D.OverlapCircle(feetTrans.position, groundCheckDist, groundLayer);
         //animator.SetBool("Grounded", grounded);
     }
 
     // Update is called once per frame
     void Update()
     {
         float xSpeed = Input.GetAxis("Horizontal") * speed;
         rigidBody.velocity = new Vector2(xSpeed, rigidBody.velocity.y);
         //animator.SetFloat("Speed", Mathf.Abs(xSpeed));
 
         if(grounded && Input.GetButtonDown("Jump"))
         {
             rigidBody.AddForce(new Vector2(0, jumpForce));
         }
 
         if(xSpeed > 0 && transform.localScale.x < 0 || xSpeed < 0 && transform.localScale.x > 0)
         {
             transform.localScale *= new Vector2(-1, 1); //flip the sprite
             //flipped = true;
         }
        // else { flipped = false; }
         
 
         //Spindash Controls
         //Charge
         
         if(Input.GetKey(KeyCode.DownArrow))
         {
             spinDashing = true;
             spinDashTimer += Time.deltaTime;
             actionText.text = "Action: Charging SpinDash!";
         }
         else if (Input.GetKeyUp(KeyCode.DownArrow) || !grounded)
         {
             spinDashing = false;
             if (spinDashTimer >= minSpinDashTime)
             {
 
                 rigidbody.AddForce(transform.right *spinDashSpeed)
                 actionText.text = "Action: Spindash!";
             }
             spinDashTimer = 0;
         }
         
     }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

133 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

`Inventory' does not contain a definition for `Add' 2 Answers

I need to add a force to an object based on the local vector of the object that is hitting it and not the world coordinates or local coordinates of the object being hit. 1 Answer

Facing the target 0 Answers

activate and speed in z axis from a pooled inactive object!! 1 Answer

2D character can't jump off of platform floating in water 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges