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 /
This question was closed Mar 10, 2013 at 03:03 PM by Meater6 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Meater6 · Mar 26, 2011 at 12:50 PM · javascriptmovementvelocity

Slowing Down When Sliding Across Walls

I have a block that has a rigidbody and a very simple script for moving around:

var speed : float = 10;

function FixedUpdate(){ rigidbody.velocity = Vector3(Input.GetAxis("Horizontal") speed,0,Input.GetAxis("Vertical") speed);
}

I also have some walls that stops the block from going off screen, but when I "Slide" across a wall, with the "wanted" velocity of the block going diagonal, the block moves much slower going across the wall than when just moving through space. This happens even when the wall has no physics material.

How do I make it so that when I slide across the wall, it moves at the same speed as when going through empty space? If there is any scripting involved in your answer, please put it in javascript.

Thanks in advance.

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

  • Sort: 
avatar image
0
Best Answer

Answer by Meater6 · Aug 24, 2011 at 05:24 AM

Second Solution!!!

Much better than the last, change the physics material to something frictionless. Works perfectly!

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 Meater6 · Mar 28, 2011 at 12:41 PM

Problem Solved!

I was able to use Mathf.Clamp to create borders for my block, instead of actual colliders. Here is my completed script:

var speed : float = 10; var height : float = 2;

function Update(){ transform.position.y = height; }

function FixedUpdate(){ rigidbody.velocity = Vector3(Input.GetAxis("Horizontal") speed,0,Input.GetAxis("Vertical") speed);
transform.position.x = Mathf.Clamp(transform.position.x,-20,20); transform.position.z = Mathf.Clamp(transform.position.z,-20,20);

}

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

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Movement using rigidbody.velocity to apply a constant force until stop 1 Answer

Make so the script only moves and makes actions to the gameObject that its attached to. 2 Answers

Stop A player Turning at Specific Point. 1 Answer

Enemy AI With changing Player 0 Answers

Movement script, moving up when moving positively in z axis 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