Skip to main content

Pulling and Pushing

  • Chapter
  • First Online:
Book cover Game Programming with Unity and C#
  • 2409 Accesses

Abstract

In this chapter, we'll make use of raycasting to allow the player to point their camera at a GameObject with a Rigidbody and hold left-click to pull the object toward them or right-click to push it away from them. Rather than pulling and pushing by moving the Transform directly, we'll apply force to the Rigidbody so that the physics system handles the motion instead for us.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Casey Hardman

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Hardman, C. (2020). Pulling and Pushing. In: Game Programming with Unity and C#. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5656-5_37

Download citation

Publish with us

Policies and ethics