Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
0
Question by Dartison · Dec 17, 2015 at 04:23 AM · velocityphysics2dplayer movementboxcollider2d

Creating a Trampoline type object?

I've been thinking about how to script a trampoline type object.

I'm just trying to work on my coding by scripting 2D elements and the first one I want to try is a trampoline type object.

For simplicity sake lets just say the player falls or jumps onto the object, the object then sends the player X distance in the air.

I did some messing around and the effect I got looks more like teleporting, it wasn't smooth. I wouldn't say I was going in the right direction, I am rather new at this.

What would be a good way to do this?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by OncaLupe · Dec 17, 2015 at 07:14 AM

Like most things in Unity, and programming in general, there's many ways to do things. It depends on how you have your movement system working.

If you're using a physics based movement, then the trampoline can probably just use the player's rigidbody AddForce() to push them upwards and let the physics system do the work. However if you're manually moving to positions, you may have to send a command to the player movement script, and have it move the player upward, similar to however you trigger a jump.

If you can show your movement code (provided you've gotten that far as you mentioned you're just starting), then we can possibly provide some more specific info.

Comment
Add comment · Show 1 · Share
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
avatar image Dartison · Dec 17, 2015 at 05:02 PM 0
Share

If you want to see the entirety of my Player file here it is: https://dl.dropboxusercontent.com/u/3801241/Code/Player.cs

I went through like a 9 part tutorial doing basic stuff like movement, jumping, wall jumping, camera following, physics, and moving platforms.

Since it was my first time in Unity and writing C# (I came from Java so it was pretty easy) then I don't fully understand what I did in the tutorial nor do I have a good grasp on the Unity API or thinking clearly how to go from A to B when trying to code something.

But there is the Player file, the tutorial didn't use rigidbody, it used BoxColliders and Raycasting so I'm not sure if AddForce() can be applied here.

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

33 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

Related Questions

Unity Player bumps when falls and dash 0 Answers

how to clamp( set max value) the velocity of a 2d rigidbody? 1 Answer

Choosing speed and direction of AddForce 1 Answer

Change the "jumping speed" in the FirstPersonController by using another script 0 Answers

Moving player left and right (HELP) 1 Answer


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