Source SDK

Source SDK

Pacca 2016 年 10 月 9 日 下午 12:34
How to make an object rotate to face the player (Portal 2)
How would I make a point entity always attempt to point in the direction of the player? Despite some intense google searching, I found nothing on how to do this in Hammer. The best I got was how to make an object rotate forever at a given speed, which obviously isn't what I need. What should I parent the entity to to make it rotate like this?
引用自 Mandrew:
Hey Pacca, here is a way to do it in steps:
Looking at player on sight (setting up)
1. Make a brush entity of the texture of your choice.
2. Make the brush entity to a func_tank (name this entity)
2. Make an npc_enemyfinder (name this entity)
3. Make an ai_relationship (optional to name)

Setting Up The Entities

1. ai_relationship
1. "subject(s)" = Name of your npc_enemyfinder
2. "Target(s)" = player
3. "Disposition" = Fear
4. "Start Active" = Yes
2. npc_enemyfinder
Keys:
1. "FieldOfView" = -1 (optional if you want the object to see you in every direction)
Outputs:
Output Target Input
OnFoundEnemy The name of your func_tank SetTargetEntity
OnLostEnemy The name of your func_tank ClearTargetEntity
OnLostEnemyLOS The name of your func_tank ClearTargetEntity

3. func_tank
1. Rate of Fire = 0
2. "Yaw rate" = "Speed of Left/Right rotation"
3. "Pitch rate" = "Speed of Up/Down rotation"
4. "Yaw range" = "How far this entity should rotate from left to right" (180 means it can rotate all around)
5. "Pitch range" = "How far this entity should rotate from up to down" (180 means it can rotate all around)
Flags
Active (Checked)
Non-Solid (Optional)
4. Parent the entities you want to func_tank and you should have rotating objects.

EDIT: If you want your entity to always face the player no matter if it is visible or not, let me know. You can always friend me for hammer editor help, I also just noticed you were the creator of the map "Weaponry in Portal 2", good map by the way :).
< >
目前顯示第 1-8 則留言,共 8
holly’s tea 2016 年 10 月 9 日 下午 1:40 
I believe
func_tracktrain has a option to face the player - but do you need an entity that looks
a) same direction like the player
b) towards the player
Rectus 2016 年 10 月 9 日 下午 1:43 
There might be an entity for it, but I can't remember. The only way I know for certain is with a script. Here is one I made for L4D2, but it should work for Portal 2 as well.
https://developer.valvesoftware.com/wiki/L4D2_Vscript_Examples#Making_an_entity_orient_itself_toward_a_player
Pacca 2016 年 10 月 9 日 下午 2:14 
I need the entity to face towards the player, preferably with some lag in it's movement. Looking at the wiki page for func_tracktrain, as well as it's info in hammer, doesn't seem to reveal a feature like what I need.

I also don't have any experience with scripts or how to package them with maps, so I'd prefer an entity oriented approach (I appreciate the answer, though, and will probably use it if push comes to shove).
Pacca 2016 年 10 月 9 日 下午 3:06 
I tried implementing the script, and I can't get it to work. I removed the if statement for checking for survivors because that obviously won't work in portal 2. However, the script still seems to have no effect. I applied it to the entity at hand, and then tried to apply it to a func_tracktrain and parented the entity I want to move to it. It still sits as if nothing has changed. I know the object can be parented properly, so that isn't an issue.
Moltard 2016 年 10 月 9 日 下午 9:36 
Func door rotating can rotate to a specific angle.
Pacca 2016 年 10 月 10 日 上午 12:54 
Can I specify that angle based on the players position?
Snoopy 2016 年 10 月 10 日 上午 3:12 
引用自 Pacguy64
Can I specify that angle based on the players position?

Not sure but maybe point_anglesensor would work
此討論串的作者認為本留言為原主題提供了解答。
Mandrew 2019 年 3 月 28 日 下午 7:34 
Hey Pacca, here is a way to do it in steps:
Looking at player on sight (setting up)
1. Make a brush entity of the texture of your choice.
2. Make the brush entity to a func_tank (name this entity)
2. Make an npc_enemyfinder (name this entity)
3. Make an ai_relationship (optional to name)

Setting Up The Entities

1. ai_relationship
1. "subject(s)" = Name of your npc_enemyfinder
2. "Target(s)" = player
3. "Disposition" = Fear
4. "Start Active" = Yes
2. npc_enemyfinder
Keys:
1. "FieldOfView" = -1 (optional if you want the object to see you in every direction)
Outputs:
Output Target Input
OnFoundEnemy The name of your func_tank SetTargetEntity
OnLostEnemy The name of your func_tank ClearTargetEntity
OnLostEnemyLOS The name of your func_tank ClearTargetEntity

3. func_tank
1. Rate of Fire = 0
2. "Yaw rate" = "Speed of Left/Right rotation"
3. "Pitch rate" = "Speed of Up/Down rotation"
4. "Yaw range" = "How far this entity should rotate from left to right" (180 means it can rotate all around)
5. "Pitch range" = "How far this entity should rotate from up to down" (180 means it can rotate all around)
Flags
Active (Checked)
Non-Solid (Optional)
4. Parent the entities you want to func_tank and you should have rotating objects.

EDIT: If you want your entity to always face the player no matter if it is visible or not, let me know. You can always friend me for hammer editor help, I also just noticed you were the creator of the map "Weaponry in Portal 2", good map by the way :).
最後修改者:Mandrew; 2019 年 3 月 28 日 下午 7:36
< >
目前顯示第 1-8 則留言,共 8
每頁顯示: 1530 50

張貼日期: 2016 年 10 月 9 日 下午 12:34
回覆: 8