Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Acrocatic - Highly customizable 2D platforming character

Discussion in 'Assets and Asset Store' started by RobinBrouwer, May 7, 2014.

  1. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    Any word from the Dev on an update?
     
  2. dimes23

    dimes23

    Joined:
    Mar 26, 2013
    Posts:
    7
    This is abandoned, or it seems to be... The devs need to update this asset ASAP or other assets like Corgi Engine are going to kill this awesome asset.
     
  3. joubqa

    joubqa

    Joined:
    Jul 8, 2014
    Posts:
    13
    I hope it's not abandoned :/ Corgi looks great but it's 50$... This had so much potential
     
  4. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    The developer posted on the last page explaining the situation. Hopefully he will be able to return to it soon.
     
  5. joubqa

    joubqa

    Joined:
    Jul 8, 2014
    Posts:
    13
    Has anyone added Attacks to the controller that they'd wanna share?
     
  6. FlowStateGames

    FlowStateGames

    Joined:
    Jul 6, 2012
    Posts:
    8
    Okay so, a couple things:

    If the devs have lost the ability to continue development on this, is there any way we could fork the code and keep it in a private repository? Maybe only allow access to it for people who have bought the product?

    There is an awful lot of optimization to be done on the code. I've done quite a bit, and would love to share that, but I don't want to violate the license of the asset. How can I do this?

    For anyone now running Unity 5: you need to go through the code and refactor it to take into account that rigidbody2d and other components are no longer cached automatically. I would suggest caching it yourself.

    Finally, the only thing that kills me about the movement of the character is that all your velocity dies when you hit the ground after a jump. I'm having difficulty seeing where this happens. Any help would be appreciated.
     
  7. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    285
    FlowStateGames:
    I suppose that the grounds physics material friction is taking place when you land. You could catch that original value and make it lerp again from zero at a certain speed; maybe the slice effect will be activated, that's something i just don't know.

    ¿Could you post an example of how are you doing the rigidbody2ds refactoring? ¿are you taking about the mandatory use of GetComponent in Unity 5?
     
  8. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Hi there everyone! Good news. I've been quite busy with my new job, but I finally have time to get back to Acrocatic! I'm aiming to release v1.2 with extra features and Unity 5 support this month. So I'm stretching the 'early 2015' promise a bit haha. ;) I just fixed a few bugs and added a feature for the moving platform to wait a few seconds at a waypoint (of course you can change the time yourself). So stay tuned for more! :)

    @FlowStateGames:
    I'm interested in what you refactored for Unity 5. I haven't had the time to dive into all the stuff that changed in Unity 5, so your refactored code would be really helpful. You can send it to support@battlebrothers.io. And I share your pain with hitting the ground and losing velocity. I'm having a hard time myself to fix this. It's something I have a problem with a lot when using physics based platforming solutions. You can make the platform's friction lower, but that also makes the character slide on the platform. You have to play with several values to fix this, or do some stuff with code like jocyf said. I have yet to find the perfect setup myself.
     
  9. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    @FlowStateGames:
    I couldn't help myself and started tinkering around based on @jocyf's solution. Well, it kind of works! I'll add it to version 1.2 as an experimental feature which is disabled by default. Here's the code if you want to add it yourself:

    Code (CSharp):
    1. // Player.cs
    2. // Public variables
    3. [Tooltip("You can enable this to keep the player's velocity when hitting the ground. This is experimental and currently defaults to false.")]
    4. public bool keepVelocityOnGround = false;
    5. [Tooltip("The timer used for the remembering the player's velocity when hitting the ground. Don't give this a high value.")]
    6. public float groundedVelocityTime = 0.05f;
    7.  
    8. // Private variables
    9. private float groundedXVelocity;            // Remember the X velocity when the player hits the ground.
    10. private float groundedTimer;                // Timer for how long the player should ignore the friction when hitting the ground.
    11.  
    12. // Inside FixedUpdate()
    13. // If the groundedXVelocity is active and keepVelocityOnGround is activated...
    14. if (keepVelocityOnGround && groundedXVelocity > 0) {
    15.     // ... set the player's X velocity to the initial velocity when hitting the ground.
    16.     SetXVelocity(groundedXVelocity);
    17. }
    18.  
    19. // Inside Update()
    20. // If the groundedXVelocity is higher than 0 and keepVelocityOnGround is activated...
    21. if (keepVelocityOnGround && groundedXVelocity > 0) {
    22.     // ... run the timer.
    23.     if (groundedTimer > 0) {
    24.         groundedTimer -= Time.deltaTime;
    25.     } else {
    26.         // Make sure the groundedXVelocity is set to 0.
    27.         groundedXVelocity = 0;
    28.     }
    29. }
    30.  
    31. // If player is grounded and not jumping through a platform...
    32. if (groundCollider && !jumpingThrough) {
    33.     // If the player isn't grounded yet and keepVelocityOnGround is activated...
    34.     if (keepVelocityOnGround && !grounded) {
    35.         // ... set the groundedXVelocity to the current X velocity.
    36.         groundedXVelocity = rigidbody2D.velocity.x;
    37.         // Start the groundedTimer.
    38.         groundedTimer = groundedVelocityTime;
    39.     }
    40.  
    41.   // Set grounded to true.
    42.   grounded = true;
    43.  
    44.   // Rest of the code...
    45. }
    Let me know what you think. :)
     
  10. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
    RobinBrower, i´m very happy you´re back!
    Your Acrocatic still the best Platform Controller in the Asset Store.
    What´s your planned features for the next version? Some new animations would be awesome.
    Thanks!!
     
  11. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    For version 1.2 I'm adding some extra features, but not too many, because I want to get it into the Asset Store asap. Here's the list of features I currently have ready for v1.2:
    - Namespace for all Acrocatic related scripts.
    - Jumping through platforms (both up and down).
    - Platforms can be rotated as well (wasn't possible in 1.1).
    - Platforms can have several scripts attached. For example: moving and jumping through on the same platform.
    - Added option to not rotate a player on a slope.
    - Added option to disable scripts on death.
    - Added wait at waypoint variable for moving platforms.
    - Added experimental feature to ignore friction when hitting the ground.
    - Fixed several bugs that have been reported.
    - Refactored some code and renamed some stuff.

    And I want to add the following before releasing it:
    - Horizontal ladder movement (+ animation).
    - Add ability to stand on top of a ladder (maybe this already works by combining jump through platforms and ladders, but I have to test it first).
    - Fix some extra bugs regarding movement, jumping and dashing that have reported.
    - Add feature to reset sinking platform's position after falling. Probably with a timer you can also disable.
    - Spring/trampoline platform. Should be quite easy by giving it a bouncy physic material.
    - Unity 5 support. I guess most of my time will be spent on pushing it to Unity 5.

    As you can see there isn't much work left to be done and I think releasing it this month is quite reasonable. :)
    I'll keep you all updated!
     
  12. FlowStateGames

    FlowStateGames

    Joined:
    Jul 6, 2012
    Posts:
    8
    Hey Robin, glad to hear that the new job is going well, and that you've got time to devote to Acrocatic. I'm sure everyone here understands RL priorities take precedence sometimes.

    First off, I certainly hope I didn't sound condescending when I mentioned that there was 'a lot of optimization' to be done. It's certainly easier to refactor code than it is to write it in the first place!

    As context, I'm working on a pvp platformer with weapon combat. While Acrocatic as it stands is a fantastic foundation for me, there are some tweaks I need to make to suit my design. As I'm moving through the code to figure out where to tweak, I'm refactoring to make it easier for future users to do the same (for instance, some sort of slider or bool for 'physics platformer' to 'arcadey platformer' in terms of tightness of movement, air control, and momentum).

    I would love to contribute a pull request to the code, fork it, or even just send my ideas and refactors to you guys and see if you think any of it is worthwhile.

    Oh, and one last thing, in terms of a wishlist for v1.2: dynamic dash length, such that if the player releases the dash button before the standard dash time is finished, the dash ends. If that can't make it into the next version, I'll be adding it myself, and would be glad to send over the solution I come up with.

    All in all, Acrocatic is awesome! Hopefully I can post here soon with a screenshot or demo of the Acrocat playing with projectiles.
     
  13. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Don't worry, it didn't sound condescending to me at all. :) I always appreciate feedback and refactored code. It's a great help and usually allows me to learn a bit more about Unity, so that's great. I created Acrocatic while learning Unity myself, so I always knew the code could be way better. Especially in terms of optimisation.

    Your tweaks sound really good. Acrocatic was always meant more as a foundation you can tweak yourself to suit your needs, so it's great to hear that's working out for you. :)

    I'll add your feature request to the backlog. Not sure if I'll be able to add that one for v1.2, but we'll see.

    Screenshots and demo's of what you're working on are great, so if you have any, please do share!

    I'm thinking of compiling a list of games made/being made with Acrocatic, so if anyone else wants to share, you can post it in this thread. It's always great to see games working with Acrocatic. Makes me proud for creating it. :)
     
  14. FlowStateGames

    FlowStateGames

    Joined:
    Jul 6, 2012
    Posts:
    8
    Awesome! I've currently put the character controller on the backburner while I work on procedural generation, but once I get back to working on it, I will certainly send screenshots and a demo.

    Just out of curiosity, how would you feel about creating a private github repository where those who purchased Acrocatic could submit issues, or fork and send pull requests?
     
  15. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Great! Good luck on the procedural generation. :)

    That's a good idea. Not sure how many would be interested in a private repository like that. I'll think about it. :)
     
  16. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Hey there, first off glad to see you back its been a while

    So ive been learning a lot more about scripting lately since my programmer quit and had a few questions, one of which was already addressed by FlowStateGames regarding the friction, i haven't tested out the new script but il see how well it works if i can get it loaded in successfully.

    What i actually came to ask about was jumping on vertical moving platforms. I noticed that the player is completely fune jumping when the platforms move horizontally but if the platforms are moving upwards or downwards thenthe player seems locked to them and jumping wont work

    I did however mess about with the sinking platforms and discovered that you can jump at least once while the platform is sinking vertically but only once as if you land back on the platform while it is still sinking then you will be locked to it and unable to jump, i even set the gravity scale to -1 so they would sink upwards and the results were the same

    anyways was wondering if there was any way to fix it, where about in the scripts does it determine if you can jump on a vertically moving platform like with the sinking ones

    p.s. You mentioned bouncing platforms, i couldn't get them to work with the bounce material but i did get them to work by using the moving platform script and having the speed set high, works surprisingly well
     
  17. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    p.p.s

    I moved all the code in for keeping velocity upon jumping, it seems to work really well, much better than before and it does keep most of the velocity, i cant gauge how high to set the grounded on velocity numerical value as the difference seems so minute, has anyone run any tests with it yet?
     
  18. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    The bug you're mentioning with vertical moving platforms is something I've fixed recently. Now that you mention sinking platforms, I think the same issue for the moving platforms is causing problems with sinking platforms. I'll fix that for v1.2. Here's the code if you want to fix it yourself. :)

    Code (CSharp):
    1. // Inside PlayerJump's Update() function.
    2. // Reset total jumps allowed when not performing a jump and grounded or when on a moving/sinking platform.
    3. if (!jump && (player.grounded || player.IsStuckToPlatform()) && ((Mathf.Round(rigidbody2D.velocity.y) == 0) || ((player.OnMovingPlatform() || player.OnSinkingPlatform()) && rigidbody2D.velocity.y == player.GetPlatform().rigidbody2D.velocity.y))) {
    4.     jumps = doubleJumping.totalJumps;
    5. }
    6.  
    7. // Inside Player class.
    8. // Check if the player is on a sinking platform.
    9. public bool OnSinkingPlatform() {
    10.     return playerPlatform.OnSinkingPlatform();
    11. }
    12.  
    13. // Inside PlayerPlatform class.
    14. // Return if the player is on a sinking platform and the platform is sinking.
    15. public bool OnSinkingPlatform() {
    16.     return OnPlatform() && platformClass.PlatformTypeIs(PlatformTypes.Sinking) && platformClass.IsSinking();
    17. }
    18.  
    19. // Inside Platform class.
    20. // Check if the platform is actually sinking.
    21. public bool IsSinking() {
    22.     return sinking.IsSinking();
    23. }
    24.  
    25. // Inside PlatformSink class.
    26. // Check if the platform is actually sinking.
    27. public bool IsSinking() {
    28.     return sinking;
    29. }
    Hmmm I thought bouncy platforms would be just a matter of changing the physics material. Thanks for the tip. I'll look into it if I can't get it to work. :)

    Great to hear that it's working for you. I played with several values and found the default to be the best. You don't want to make it too high, because then you'll keep moving at the same velocity for that period even when you stopped moving when you hit the ground. :)
     
  19. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
     
  20. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Forgot to draw the boxes in those last 2 images, here they are
    platform
    jump4.png
    platformsink
    jump5.png

    ive also run a few tests as to determine why the player may not be jumping on vertical platformsdespite the script having no errors, i made the hitbox radius bigger and saw no change, still didnt work

    turned the player circle collider back on, still didnt work

    tried using the origional moving platform prefab that came with the pack, still didnt work

    EDIT: okay i put the script over the original one in the playerjump script likeas i didnt see it and now it works on the sinking platforms but not the moving platforms, il keep looking into it
     
    Last edited: Mar 13, 2015
  21. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Weird that it isn't working on the moving platforms. It works great for me.
     
  22. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    It is strange, any chance you could email me those 5 scripts over so i can compare them and see if they're any different? or maybe its the moving platforms themselves, do they need a to be in the platform layer because i have mine in the ground layer because of how my game is being built
     
  23. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Yes, it's checking for the Platform layer. So that's probably why there's an issue.
     
  24. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Ahh i see, i havnt been using the platform layer because i get this error and it lags like hell, its been doing it ever since i updated to the new version which you sent over to me a while ago platform1434234525.png

    so i went to the script and it looks like this, doesn't have any errors or anything so not sure why its happening
    platform3464364363.png

    il look into it but if you can think any reason as to why that would be great

    also while im here ive been having trouble getting the player jump to trigger other scripts, see im trying to have it so when the player jumps it triggers a different event in a different script completely. Here is what i have at the moment, it doesn't seem to work but i don't have any errors, i saw that if (playerJump) was used in a lot of the other scripts so thought it would but the debug shows nothing
    jump25434663.png
    i also tried it with player.jump == true and that didnt work along with a few others, have you any idea how i could get this to work?

    also i know ive been asking a lot of advice so i fixed something and thought id share it, i noticed that when you stick to the wall of a linking platform as it falls your character stays in place, so i use this script to destroy the walls of the sinking platforms when the player activates it

    put these on line 31 and 32
    public GameObject destroy1;
    public GameObject destroy2;

    put this after the line that says platform.Sink();
    Destroy(destroy1);
    Destroy(destroy2);

    then in the inspector link your walls to it, hope this comes in handy
     
  25. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    I'm not sure what's causing the issue. What version of Unity are you using?

    About the script you attached: is that script also connected to the player? Because GetComponent only checks for components on the same object. If the script isn't on the player, you can't get the PlayerJump script like that. You should get the Player object by tag or something like that and then get the PlayerJump component. Or is it attached to the same object?
     
  26. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Using unity 5, the latest version, ive had no trouble with anything else in acrocatic but i think it did the same thing before updating so it probably isnt related to unity itself

    okay the gist is i have these boxes which will appear and disappear when the player jumps, the script i showed you is the script i have attached to the boxes, it works fine if i use getbuttondown but then i can mash the keys while in mid air and it still changes, so i thought i would try and link it to the actual act of jumping itself

    basically all i want to do is have this script im writing be triggered by the player jumping but the script itself cant be attached to the player because it would mess with his box colliders

    any ideas? ive tried doing it the other way around where the playerjump script triggers the box changing script but i havnt figured it out yet
     
  27. cfree

    cfree

    Joined:
    Sep 30, 2014
    Posts:
    72
    Hi RobinBrouwer. Do you still have plans to release 1.2 this month? No bad news?
    I am looking forward the new version!
    Thanks a lot and good luck with the job :)
     
  28. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    I haven't tested Acrocatic in Unity 5 yet, so I guess there are some changes in Unity 5 that messes up part of Acrocatic.

    What you're doing right now is trying to access the PlayerJump and Player scripts on the boxes. And those don't exist. You have to get them from the player. Here's how you do that:

    Code (CSharp):
    1. GameObject playerObj = GameObject.FindWithTag("Player");
    2. PlayerJump playerJump = playerObj.GetComponent<PlayerJump>();
    3. Player player = playerObj.GetComponent<Player>();
    4. Debug.Log (player.grounded);
     
  29. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Yup, still aiming for this month! :)
     
  30. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    ah excellent that should really help out

    one last question, what should i put for the if statement in void update, the phrase if (PlayerJump) results in the error
    cs(57,29): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

    thanks for your patience with me by the way im still getting used to all this because my programmer who i was working with quite so im picking up where he left off
     
  31. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    You want to check if the player is jumping right? Then you could check for !player.grounded.
     
  32. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Tried GetButtonDown ("Jump) && !Player.grounded. but there was an error on the console which says
    cs(57,69): error CS0120: An object reference is required to access non-static member `Acrocatic.Player.grounded'
     
  33. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    player.grounded. Small 'p'. You're now calling 'grounded' on the class instead of the instance. :)
     
  34. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    almost there, when i used player.grounded it came up in red writing saying player does not exist in the current context so i went to make a private player variable at the top and it sort of works but the boxes change every update rather than when the player jumps so i got like 999 error longs in a few seconds in the console

    here is the script so far
     

    Attached Files:

  35. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    In Awake you should remove the Player in front of 'player'.
     
  36. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Done that, i still get the blocks flashing every update rather than when the player is jumping though, no actual errors though this time just two warnings saying
    cs(58,25): warning CS0642: Possible mistaken empty statement
    cs(31,36): warning CS0219: The variable `playerJump' is assigned but its value is never used

    im stumped, been trying to get this to work for like 6 hours now lol
     
  37. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Try this. Hopefully it pulls you in the right direction. I have to go to bed now. Hope you fix your issue. :)
    Code (CSharp):
    1. if (Input.GetButtonDown("Jump") && !player.grounded) {
    2.   myBox.enabled = false;
    3.   mySprite.enabled = false;
    4. } else {
    5.   myBox.enabled = true;
    6.   mySprite.enabled = true;
    7. }
     
  38. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Okay, thank you for all your help, i still get the "cs(31,36): warning CS0219: The variable `playerJump' is assigned but its value is never used" warning but il work on it and see if i can get it functioning by tomorrow
     
  39. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    haha okay i actually got it to work now believe it or not, the boxes do change like they are suppose to however ive encountered a new problem, see when you jump from the boxes you arent technically grounded because your on a platform so they go out of sync, il try and upload a video to youtube to show you what i mean tomorrow but for the meantime im just glad it actually works so thank you for all your help
     
  40. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    You're welcome. You're getting that warning because you're not using the playerJump variable. So you can just remove / comment out all playerJump references if you want. :)

    I didn't really understand what you were trying to do before, but now I think I do. You want to disable/enable the box each time the player jumps. So when they're enabled and you jump, they get disabled. And when you jump after that, they get enabled again. So they toggle based on your jumping.

    Here's one final snippet before I'm off to bed. ;)

    Code (CSharp):
    1. // If the player tries to jump and is still grounded.
    2. if (Input.GetButtonDown("Jump") && player.grounded) {
    3.   // Enable or disable the boxes based on the current state.
    4.   myBox.enabled = !myBox.enabled;
    5.   mySprite.enabled = !mySprite.enabled;
    6. }
    So now the boxes only get disabled when the player starts jumping when he's still on the ground. You can remove the whole 'else' part from my previous snippet. Hope it helps.
     
  41. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Hey, the snippet you attached works sort of but ive kind of realized something from it working, see i found at that because the conditions are if GetButonDown "jump" and player.grounded then it will only switch if the player is grounded and wont change if your jumping from a wall a ladder or one of the platforms with the script attached

    I tried adding the variables || player.Onplatform || player.Onladder but i got an error, i think the absolute best way to get this to work properly is to tie it to a part of the script which ever part of jumping has to run through, though im not sure which part would be the best part to access

    so what do you think? which part of the script should i call and what would i have to attach to get it to work right, also when im finished with this do you want me to send some prefabs and the scripts over so you can add it into v1.2? only seems fair since your helping me with it
     
  42. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Inside PlayerJump there is a function called 'InitJump'. This function is used to make the jump. You can do it the other way around and make all platforms appear/disappear within that function. You'd have to loop through all the corresponding platforms and call a function on each one to make them appear/disappear.

    No need to send it over, but thanks anyway. :) Adding those kind of platforms for v1.2 is a bit out of scope. And I don't want to delay v1.2.
     
  43. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Ahh right, il start looking into it and see how it goes, might try and trigger it from the jump script itself but not sure yet, gonna look some more into scripting and learn a bit more before i come back to this.

    Oh i did wonder if you could enlighten me on something else though, im trying to make the player shoot and wondered whats the best way of making it shoot in the direction the player is facing, i noticed in the player script there is an enum for direction but cant seem to link it, firePosition is where the bullet is fired from but when you put in firePosition.forward it shoots it forward in a 3d perspective rather than a 2d perspective, i got this script from the unity beginner direction3453464.png scripting tutorials, here is what mine look like so far, any ideas?
     
  44. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    285
    To make the player fire something i did this:

    Code (CSharp):
    1. int dir = player.facingRight ? 1 : -1;
    2.            GameObject FireObj = (GameObject) Instantiate(firePrefab,  new Vector2(transform.position.x + 1.05f * dir, transform.position.y), Quaternion.identity);
    3.             if(dir == 1)
    4.                 FireObj .rigidbody2D.AddForce(Vector2.right * speed);
    5.             else{
    6.                 FireObj .rigidbody2D.AddForce(-Vector2.right * speed);
    7.                 InvertSpriteDirection(FireObj .transform);
    8.             }
    9.             internalBulletRatioTime = Time.time + ratio;
    10.         }
    You could addForce in one single line multiplying directly by the dir variable.:
    Code (CSharp):
    1.  
    2.      shurikenObj.rigidbody2D.AddForce(Vector2.right * dir * speed);
    3.  
    To invert the sprite:
    Code (CSharp):
    1. private void InvertSpriteDirection(Transform _obj){
    2.      _obj.localScale = new Vector2(-_obj.localScale.x, _obj.localScale.y);
    3. }
    And you will need to attach a new fire animation in the animator controller and add some bool variable to it. I did that modification in the original acrocatic animation code.
     
    Last edited: Mar 23, 2015
  45. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    Interesting, works a lot different to mine but looks like it works, how exactly did you declare "InvertSpriteDirection" in the script as im getting this error, i have public Direction spriteDirection; declared but i get an error stating...

    Assets/Scripts/Tutoral scripts/class scripts/Shooting.cs(57,41): error CS0103: The name `InvertSpriteDirection' does not exist in the current context

    any ideas?
     
  46. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    285
    I declared that function to clarify what it does, but it has -only- one line of code to invert the 'x' scale component. I mean, you can just NOT to declare that function and use the localscale asignment directly in your code.
     
  47. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Here's a small update on version 1.2. I'm almost done! One small feature and then I'll add the Unity 5 support. When I submit v1.2 to the asset store, I'll also upload a version for Unity 4.5 and 4.6. After v1.2 however, I will only support Unity 5. It would take me too much time to maintain several versions. As I said I'm aiming for the end of this month for the release of v1.2 and that's still the case. I've reserved tomorrow (sunday) for completing the update and submitting it to Unity. Unity needs to approve the update, so that could take a few days. I can send the new version via mail if you email your invoice number to support@battlebrothers.io, so you don't have to wait for the approval.

    Have a nice weekend everyone! :)
     
    Mr Greebone and Too-Nerd-To-Die like this.
  48. Mr Greebone

    Mr Greebone

    Joined:
    Jul 24, 2014
    Posts:
    53
    hey just encountered a bug i thought id let you guys no about, it seems the death script will stop the player from moving (assuming you have that enabled) but wont re-load the level if a script regarding game object destruction (in this case Destroy (this.gameObject);)

    i did quite a bit of messing about and i narrowed it down to involving game object destruction as i tried 2 separate destroy scripts which function differently and both made the player stop moving but would not reload the level (i used debug.console to check this) im assuming its a bug, hopefully you guys are way ahead of me and its fixed in v1.2 which im looking forward to
    oh regarding 1.2, are there any new features or is it mainly small fixes, would love to know
     
  49. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    Just submitted version 1.2 to the Asset Store! It's pending review, but if you want the new version right away you can send an email to support@battlebrothers.io. Don't forget to add the invoice number and if you want the Unity 5 version or the older one. These are the changes: http://battlebrothers.io/acrocatic/#v1.2.

    Hope you guys will like it. :)

    What GameObject are you destroying? Because if it's the Death object, the timer won't run and the level won't restart. Not sure what else you're destroying that could cause issues. Could you give some extra information?
     
  50. RobinBrouwer

    RobinBrouwer

    Joined:
    Dec 9, 2013
    Posts:
    114
    It took me quite some time to add the Unity 5 support. Had to redo the animator and make some extra changes to the code. But it was worth it. :)