Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Earth-O-Matic · Apr 11, 2011 at 05:21 AM · physicsforceangleignoreconstant

Player not able to climb an angle

So I have a game where the player walks back and forth across the screen I need to keep him at a constant force so originally I was moving him using Translate and Time.deltaTime

This allowed him to move across the screen at a constant speed just fine but I then ran into a number of collision issues. he would get stuck in a wall if flung across the screen too fast instead of turning around when he hit it or he would get stuck in other collision.

So I switched to using the physics engine to add force to him and I got him moving at a constant force now but as soon as he hits a ramp he stops. So my question is how can I get him to ignore this incline? I thought putting constant force under and Update function would push him along how I needed but he wont climb up the angle.

Any thoughts? Thanks as always!

Here's snip of the code I'm using...

private var move = (Vector3(1,0,0));

function Update () {

 rigidbody.AddForce(move, ForceMode.Impulse);

}

// Hit edge of screen - invert x direction. function OnCollisionEnter (hit : Collision)

{

var bump = hit.gameObject.tag;

//hit wall turn around if( bump == "wallX") { //rotate physically transform.RotateAround(transform.position, Vector3.up, 180); //change direction move = (Vector3(-1,0,0)); rigidbody.AddForce(move, ForceMode.Impulse); Debug.Log("hit"); }

more code and all but this is the code that turns him around.

Another acceptable answer would be to have a way to improve my collision issues when using transform.Translate and Time.deltaTime as this way has been the most accurate way for me to move the player the way I want.

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 Earth-O-Matic · Apr 12, 2011 at 05:31 AM

Alright so if any on is interested here's how I solved my issue.

I decided to stick with transform.translate to move the player since it is constant movement that is more predictable. But I changed the collision to capsule as SuperCheese suggested. This keeps the player from getting hung up on other collision in the level.

As for getting hung up on edge zone walls. I simple deactivated the collision on those walls after the player hit it so that he did get knocked back into it it would not turn him around. The wall turns back on after the player hits the opposite wall. This keeps the player from hitting the wrong wall then turning around and getting stuck walking towards it. Thanks for looking!

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 Ariel J · Apr 13, 2011 at 09:24 AM 0
Share

Nice work mate :)

avatar image
0

Answer by Ariel J · Apr 11, 2011 at 06:07 AM

What type of collider are you using? The best for this situation would probably be a capsule with a frozen rotation.

You may want to use the default force mode too.

When you were using translate and deltaTime, were you using a character collider? The character collider is designed for these types of interactions.

Lastly, have a look at how the character motor script handles movement. I'm not too sure where in the script it does it, but I know that it uses translate and Time.deltaTime

-Aj

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 Earth-O-Matic · Apr 11, 2011 at 08:33 PM 0
Share

I'm using a mesh collider I was not using a character collider though with delta time. I'm also not using character motor script this is something I made from scratch to move the player back and forth that turned into a much larger script.

$$anonymous$$y issues with delta time was that if the player got knocked backwards and hit the wall that is supposed to turn it around it would turn the player around and he would become stuck walking against the wall. I fixed that by deactivating the collision after the player collided with the wall. I'll try some of this once I get home tonight.

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

No one has followed this question yet.

Related Questions

how to get starting velocity of an object, which is thrown with a 45 degree angle and will pass some (x,y) point 0 Answers

How to calculate the angle of a trajectory to hit the target 1 Answer

Hovercraft Physics Problems 1 Answer

Making a paper like object on Unity. 2 Answers

[Solved]Moving object at constant speed. 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