Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Jojoba007 · Feb 15, 2017 at 10:12 AM · instantiateprefabcollidersforce

Not counting score when jump landing is on same platform

alt text

I have an endless jumper where a new platform gets instantiated after reaching the next platform by entering it's box collider as trigger. Also when you enter the platform's box collider the score gets inscreased by one.

But here is the problem, if the force on the jump is to low you still land on the same platform so the score gets increased although you are still on the same platform. How can I prevent this from happening without changing the settings on the jumpforce? I was thinking on checking if I'm still on the same platform, but since I'm new to Unity I don't know really where to start.

Can someone help me in the right direction?

instantiate-platform.jpg (24.0 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Jojoba007 · Feb 16, 2017 at 08:19 AM

Got it working, it became another approach, but its working.

 // Increment score and instantiate platform. Also check if last platform was allready landed on
                 if (ScoreManager.instance != null && GameManager.instance != null) {
 
                         if (target != lastPlatformJumpedOn) {
 
 
                             lastPlatformJumpedOn = target;
                             ScoreManager.instance.IncrementScore ();
                             ScoreManager.instance.HighScore ();
                             GameManager.instance.CreateNewPlatformAndLerp (target.transform.position.x);
                         }
                     } else {
                         ScoreManager.instance.IncrementScore ();
                         GameManager.instance.CreateNewPlatformAndLerp (target.transform.position.x);
                         lastPlatformJumpedOn = target;
                     }
 
                 
                 
 
             }
         }
Comment
Add comment · 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
0

Answer by AmoVires · Feb 15, 2017 at 11:45 AM

You can store character position pre and post jump. If distance travelled is >x then add score?

Comment
Add comment · Show 3 · 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 Jojoba007 · Feb 15, 2017 at 01:51 PM 0
Share

@AmoVires That sounds like a good approach, thanks. Could you maybe give me a little bit more info on how to handle this in code?

avatar image AmoVires Jojoba007 · Feb 16, 2017 at 01:15 AM 0
Share

@Jojoba007 Easiest way is 2 variables I guess. Upon jumping you save his position (x?) into a variable and upon landing you save his new position into another variable.Then compare them. OnCollision/OnTrigger Enter/Exit should do the trick.

P.S Sorry about late reply, fell asleep.

avatar image AmoVires AmoVires · Feb 16, 2017 at 01:57 AM 0
Share
 void OnTriggerExit2D (Collider2D other)
     {
         x = Player.transform.position.x;
     }
     void OnTriggerEnter2D (Collider2D other)
     {
         y = Player.transform.position.x;
         if (y - x > distance) {
             score++;
         }

That should do the trick.You have to do a bit of tweaking and make distance as big as the platform width

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

115 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

Related Questions

instantiated prefab doesn't follow spawn rotation 1 Answer

Call function for instantated prefab. "Object reference not set" 1 Answer

Simple Prefab Instantiate "(Clone)" Question 3 Answers

How to Change the Variables of an Instantiated Object? 0 Answers

Check if a large number of gameobjects are colliding 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