Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The player should be followed by the obstacle(spider in my game) when the player touches the extended collider of the obstacle.I made the obstacle(spider) to give the movement gestures in animator and I wrote the code but the obstacle is not following or
moving in direction .It just showing the movement (leg movements)gestures when the player collides with collider of the obstacle.

What I have tried:

I tried the code and got broken.Please help me with the code for the obstacle collider.
Posted
Updated 30-Jun-18 22:12pm
v2
Comments
OriginalGriff 30-Jun-18 8:17am    
Please don't repost if your question does not appear immediately: all of these went to moderation and required a human being to review them for publication. In order to prevent you being kicked off as a spammer, both had to be accepted, and then I have to clean up the spares. Have a little patience, please!

1 solution

Get the position of the player, and update the position of the spider relative to the player on the next update pass (i.e. change the x, y, z of the spider's Transform component to move closer to the player's (Transform) position).
 
Share this answer
 
Comments
Member 13893281 2-Jul-18 0:25am    
would you please tell me the code in update() for player
[no name] 2-Jul-18 0:40am    
Check out the "Position Constraint". Constrain the spiders position to the player's.

https://docs.unity3d.com/Manual/class-PositionConstraint.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900