• 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 thatanimator · Jun 10, 2012 at 08:20 PM · collisionstuckclimbingstates

Climbing bug, stuck in the air.

http://www.youtube.com/watch?v=pNyjXLuchXg

^^^^^ first part shows it all "working" (be it without Lerping..) second part, not working. then a slow-mo of what's going on ingame. don't mind the part where the character gets sucked down, the controllers bottom moves to the transform of the ball, and I've done the animation so that the character moves down to it's root. probably redo that, but that is not the issue :)


tl;dr: want to Lerp into a climb position when $$anonymous$$tting the trigger. right now goes into "in-air"-state. probably because the controller isn't grounded. is there a way to tell the controller it is grounded? (read only..?)



I want to be able to attach to parts of my level, like you would do in say inFamous or the like (but without the s$$anonymous$$mmying along ledges).

Got a sphere that I can place where I want to be able to climb, that triggers the animation and places the character at the center of the sphere.

The problem I have, is that it only works some times.

And when it doesn't work, the character gets stuck in it's "in-air"-state.



The part that should interest you the most is the last part of my main script called "states":



var target : Collider; var climbPos : Transform; var start : Transform; var end : Transform;

function OnTriggerEnter (trigger : Collider) {

var controller : CharacterController = GetComponent(CharacterController);

movement = GetComponent("UnityMovement");

states = GetComponent("States");

additiveBlend = GetComponent("AdditiveTest");

climbing = GetComponent("Climbing");

 if (trigger == target)
     print("Climb!");
     animation.CrossFade("climb_land", 0.3);
 
     transform.position = Vector3.Lerp(start.position, end.position, 5.0);
       additiveBlend.leanRight.weight = 0;
        additiveBlend.leanLeft.weight = 0;
        states.enabled = false;
     movement.enabled = false;
     climbing.enabled = true;
     animation.Stop("runADD");

}

function OnTriggerExit (trigger : Collider) {

movement = GetComponent("UnityMovement");

states = GetComponent("States");

climbing = GetComponent("Climbing");

 if (trigger == target)
     print("exit climb!");
     transform.parent = null;
     states.enabled = true;
     movement.enabled = true;
     climbing.enabled = false;

}


I can assume that part of the problem is that when the controller isn't grounded, I play the "in-air" animation.. Is there a way to switch the grounded to true even though it .. isn't ?


When in the climb state, I don't want to be able to move around (running and such) and therefore I disable all the scripts associated with that. T$$anonymous$$s of course also turns of the main script <_<, but I've even tried having it so that you can jump out of the climb state and having it all re-enable, w$$anonymous$$ch is kind of what I want.

But I might (should anyways..) have to put the climb part into it's own script, that could help?

My scripts are very messy at the moment, I'm basically just trying to implement my crazy ideas and hopefully get around to solving it better later :P


http://pastebin.com/Vht7Scgu the entire script, the collision checks are at the bottom

Thank you!

http://www.youtube.com/watch?v=vtuPQNPLo2U

Right now it's fun and all to jump around on the rooftops, but once you're down there's no way to get back up! :)

Comment
Add comment · Show 2
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 thatanimator · Jun 12, 2012 at 02:08 PM 0
Share

http://www.youtube.com/watch?v=ByCneo8PR40

think I solved some of it for now.. it's kinda ugly, but it works :P I'll clean it up when (mm..) I'm gonna clean up the rest of the scripts.

only problem now is that the Lerp doesn't LERP!

transform.position = Vector3.Lerp (start.position, end.position, Time.time 1.0); transform.rotation = Quaternion.Lerp (start.rotation, end.rotation, Time.time 1.0);

doesn't matter if I have Time.time or whatever number after, just snaps. any ideas?

avatar image whydoidoit · Jun 12, 2012 at 02:14 PM 1
Share

Yep - lerp's time parameter has to be a number between 0 and 1 - if it's bigger than 1 it just snaps to 1.

You should be using a time variable and adding Time.deltaTime to it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by thatanimator · Jun 13, 2012 at 11:49 AM

var blendSpeed : float = 0; var blendValue : float = 0;

blendValue += blendSpeed * Time.deltaTime;

transform.position = Vector3.Lerp (climbLocStart.position, climbLocEnd.position, blendValue);

transform.rotation = Quaternion.Lerp (climbLocStart.rotation, climbLocEnd.rotation, blendValue);

that's what I hacked together with the help of a friend and what whydoidoit said! thanks! the character blends into the climb position now!

there are times where it bugs out and the character gets stuck in the air.. but I'll take care of that later :)

got to reset the blendValue after jumping now.....hmm

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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Object moves out of own collider. 3 Answers

Player sticks to bottom of platform 0 Answers

Unity 2d, player getting stuck passing over box colliders next to each other 0 Answers

Ignore collision in particular situation 3 Answers

Still walk when collide with object 2 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